3 ms·
I write perl everyday, I never use this stuff.
by mrbig4545 11y ago
I write perl everyday, I never use this stuff.
- yati 11y agoSame here, I didn't even know about most of these, except the list interpolation trick, "@{[ fncall() ]}", which is pretty common where I work.
- xlm1717 11y agoI use a few of them in javascript. In fact, Venus can be shortened to just "+", ie. +"123234" +"1e29" +"abc" // -> NaN
- dozzie 11y agoIn 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;
- dozzie 11y agoMe too. Except maybe for goatsee operator sometimes, because it gives you a forced list context, similar to "scalar" builtin.
- jerf 11y agoNumification 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.