Perl's lack of 'in' keyword

Abigail abigail at
Wed Oct 8 15:22:28 BST 2008

On Wed, Oct 08, 2008 at 02:51:51PM +0100, Nigel Rantor wrote:
> I'm not necessarily saying that we need to replace anything that is  
> already there in the language, but why must we *add* more things that  
> that look like noise?
> Let's take "~~" for example. It's arguably harder to type than "in". And  
> by that I mean for *me* it is harder to type. I need to hit shift to do  
> it, so it's slower than 'in'.

That's streching it, and the difference is so minimal, I don't think
it's relevant. Yes, for ~~ one needs the shift key, but a shift key can
be pressed at the same time as another key (and there are shift keys
on both sides of most keyboards), and ~~ requires no replacement of
fingers between the keystrokes. 'in' requires movement of the fingers -
of the same hand even - between the two characters.

Note that ~~ is easier to search for in a text file due to getting
far less false positives on ~~ than when searching with 'in'.

>                               It is not shorter than 'in' so doesn't win  
> on speed nor brevity. It also doesn't scan like english, so whilst  
> something like:
> die "can't find it guv!" unless $thing in @set;
> reads quite nicely,
> die "can't find it guv!" unless $thing ~~ @set;
> doesn't.


  die "..." unless $thing in $sub;

is just plain weird. While '~~' isn't "obvious" (but then, neither is =~,
or even '=' for that matter), it certainly doesn't confuse people as
'in' would were it used to replace '~~'.


More information about the mailing list