5 ms·
Announcing perl1line.txt - A collection of handy Perl scripts
- symkat 15y agoIt's missing one of my favorites: perl -MData::Dumper\ 999 Quickest way to get the version of a module you're running.
- pkrumins 15y agoDoesn't work for File::Slurp, which has version 9999.19. :) Otherwise awesome thingy to query module versions.
- mike-cardwell 15y agoInteresting. I would have done it this way previously: perl -MData::Dumper -e 'print $Data::Dumper::VERSION."\n"'
- pkrumins 15y agoWorks for any module: $ perl -MLWP::UserAgent\ 999 LWP::UserAgent version 999 required--this is only version 5.833.
- mike-cardwell 15y agomike@server:~$ perl -MLWP::UserAgent -e 'print $LWP::UserAgent::VERSION."\n"' 5.835 mike@server:~$
- pkrumins 15y agoThat works, too!
- d5ve 15y agoEven shorter, as -l appends \n to all prints: $ perl -MLWP::UserAgent -le 'print $LWP::UserAgent::VERSION'
- pkrumins 15y agoEven shorter! $ M=LWP::UserAgent && perl -M$M -le "print \$$M::VERSION" Even even shorter! $ M=LWP::UserAgent;perl -M$M -Esay\$$M::VERSION
- sliverstorm 15y agoThis reminds me of that joke in which jokes have been reduced to numbers. It's nearly as obscure, too.
- pkrumins 15y agoDid Gödel come up with that joke?
- jrockway 15y agoWell, almost any module: $ perl -MFile::Slurp\ 9999 <hangs forever>
- ojosilva 15y agoI'm a fan of the "V" module. perl -MV=Data::Dumper "Quicker", if you don't count install time. cpanm -n V
- stouset 15y agoShit like this is why Perl gets under my skin. The best way to do anything in Perl always seems to be some side effect of a clever hack, instead of actually solving the damn problem expressively. The equivalent in Ruby? gem list $GEMNAME It's shorter and more clear. Take that, Perl golfers!
- pkrumins 15y agoDirect download link: http://www.catonmat.net/download/perl1line.txt http://www.catonmat.net/download/perl1line.txt
- brador 15y agoMaking this for all the different languages would be awesome. I'm thinking PHP, jquery etc. one liners.
- wx77 15y agoDo any other languages really lend themselves to the one line command tools like perl does? The only one off the top of my head would be ruby but I don't have that much ruby knowledge to judge. This kind of thing however is perl's bread and butter.
- pkrumins 15y agoBenoit Hamelin did ruby one liners - http://benoithamelin.tumblr.com/ruby1line http://benoithamelin.tumblr.com/ruby1line
- jbum 15y agoAgreed - one reason why I still love Perl so much, despite its obvious warts.
- mapgrep 15y agoCompared to Ruby, one liners are more efficient in Perl because the normally infuriating cryptic variables and defaults save space. For example in Perl you can run a foreach without naming the current iteration value and it defaults to $_. $_ in turn is the default target for many commands, like print. So Perl's `print foreach @a` becomes Ruby's `a.each{|a| print a}`. Not so bad but it adds up.