top | item 10295750

(no title)

mrbig4545 | 10 years ago

I write perl everyday, I never use this stuff.

discuss

order

jerf|10 years ago

Numification is important if you output to another language, for instance, with JSON, where the other language will care about a string showing up where a number should have been.

List interpolation is occasionally necessary for syntax reasons, though I don't think of that as an operator, but the composition of its parts.

!! is for if you don't really love the loosey-goosey nature of Perl, and want to have a function that really, truly returns a boolean, and doesn't just return something that may or may not be a value that is either falsy or not. If you think in OO you may not want people coming to depend on the exact falsy value returned, which may expose internals. Generally I just go with the general Perl/scripting language approach, except when I know I'm leaking internals that I really, really don't want people to couple to.

The rest are mostly for show.

xlm1717|10 years ago

I use a few of them in javascript. In fact, Venus can be shortened to just "+", ie.

+"123234" +"1e29" +"abc" // -> NaN

dozzie|10 years ago

In Perl, no, because + is an unary identity operator, used e.g. to properly leave function call parentheses:

  print +(1 + 2) * 3;
  print ((1 + 2) * 3);
  print (1 + 2) * 3;

yati|10 years ago

Same here, I didn't even know about most of these, except the list interpolation trick, "@{[ fncall() ]}", which is pretty common where I work.

dozzie|10 years ago

Me too. Except maybe for goatsee operator sometimes, because it gives you a forced list context, similar to "scalar" builtin.