hello haukex,
Yes, thanks, a neat little trick.
It will be useful, for example, in unfortunate shells that does not do glob expansions of the arguments. To count lines of code in test files you can glob them using your trick (I was used to put a BEGIN block there):
perl -M"5;@ARGV=glob shift" -lnE "last if /__DATA__/;$c++ unless /^$|^
+\s*#/}{say $c" "./t/*.t"
I didnt recognize what that 5 was for; manual to the rescue! require N requires a minimal version of Perl, so numbers from 0 to 5 will be all ok. Zero is more hackish ;)
This neat trick is worth to be added to shh.. dont tell! manpage (update: done!). If I can suggest a name, being the opposite of eskimo greeting I propose maori farewell
That said, i cant resist to use the maori farewell immediately..
perl -M"0;eval{require 6},@}=(40,35,0,32)" -e "print map{chr(ord($_)-s
+hift@})}(split'',$@)[12,19,0,23]"
# linux quoting:
perl -M'0;eval{require 6},@}=(40,35,0,32)' -e 'print map{chr(ord($_)-s
+hift@})}(split"",$@)[12,19,0,23]'
L*
UPDATE April 25 2019: in December I suggested to add this trick to perlsecret and is now part of perlsecret 1.014
There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.
|