Perl's lack of 'in' keyword

Iain Barnett iainspeed at
Thu Oct 9 12:11:15 BST 2008

On 9 Oct 2008, at 11:51 am, Andy Armstrong wrote:

> On 9 Oct 2008, at 01:39, Iain Barnett wrote:
>> if $a ~~ $b	#this could mean several things
> A smart match between two scalars. Clear.
>> if $a in $b		#it is clear what this means
> One scalar is in another? WTF?

What does smart match do if you pass it an array/hash/object ref? If  
it matches against the scalar part then it's not a very smart match,  

>> if a in b		#this is even better IMO
> Dunno what a and b are - so who knows what it does?
> Which is not, of course, to say that you're wrong - but that  
> readability is - to some extent - in the eye of the beholder.
> -- 
> Andy Armstrong, Hexten

The "in" implies that "b" is a collection of some sort and "a" is a  
single value of the type that b is holding.


More information about the mailing list