Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Interesting. I would have done it this way previously:

  perl -MData::Dumper -e 'print $Data::Dumper::VERSION."\n"'


Works for any module:

    $ perl -MLWP::UserAgent\ 999             
    LWP::UserAgent version 999 required--this is only version 5.833.


Well, almost any module:

    $ perl -MFile::Slurp\ 9999
    <hangs forever>


  mike@server:~$ perl -MLWP::UserAgent -e 'print $LWP::UserAgent::VERSION."\n"'
  5.835
  mike@server:~$


Even shorter, as -l appends \n to all prints:

    $ perl -MLWP::UserAgent -le 'print $LWP::UserAgent::VERSION'


Even shorter!

    $ M=LWP::UserAgent && perl -M$M -le "print \$$M::VERSION"
Even even shorter!

    $ M=LWP::UserAgent;perl -M$M -Esay\$$M::VERSION


This reminds me of that joke in which jokes have been reduced to numbers. It's nearly as obscure, too.


Did Gödel come up with that joke?


That works, too!




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: