tadman has asked for the wisdom of the Perl Monks concerning the following question:

I'm looking for a quick and dirty, but compatible and reliable, way to download and run a Perl program in one simple, cut-and-paste-able line. So far, I've come up with is:     perl -e 'eval `lynx --source http://theurlfortheprogram/`' Obviously, what you get at the URL is a Perl program without HTML formatting, such as you would get if you did this:     $ ln -s perlprogram index.html I had tried a few variations, but piping from lynx to perl, for example, seemed to take over STDIN, rendering it useless for user input. During some experimentation, I discovered a similar technique used at Ximian, where they had used sh instead, but with a pipe, presumably because their installer isn't interactive on the command line.

This is so that I can download and run a Perl program which fixes up things to that they work (i.e PATH, .cshrc, .bashrc) among other things, such as hauling over a kit of standard goodies, toys, and projectiles to put into ~/bin.

The question is, is there an easier/better way?

Replies are listed 'Best First'.
Re: One Line of Salvation
by kschwab (Vicar) on Feb 16, 2001 at 06:39 UTC
    perl -e 'use LWP::Simple;eval get "http://some/url"' Yuckie poo, though. That's scary.
      Very nice! Playing a miniscule bit of golf:
      perl -MLWP::Simple -e 'eval get "http://server/file"'
      Don't you hate it how you have to reverse single/double quotes between NT and Unix? Wonder if there's an easy way around that...
         MeowChow                                   
                     s aamecha.s a..a\u$&owag.print
        I guess you could avoid the quotes altogether... perl -MLWP::Simple -we eval -e get+q,http://server/file, Probably not a general solution, however. :)
      Nice and portable. Something I could envisage using internally in my company, but never something I would run if I didn't know what the script does!

      $code or die
      Using perl at
      The Spiders Web
Re: One Line of Salvation
by davorg (Chancellor) on Feb 16, 2001 at 13:51 UTC

    You might also find the -x command line option useful. From perlrun:

    -x directory
    tells Perl that the script is embedded in a message. Leading garbage will be discarded until the first line that starts with #! and contains the string "perl". Any meaningful switches on that line will be applied. If a directory name is specified, Perl will switch to that directory before running the script. The -x switch controls only the disposal of leading garbage. The script must be terminated with __END__ if there is trailing garbage to be ignored (the script can process any or all of the trailing garbage via the DATA filehandle if desired).
    --
    <http://www.dave.org.uk>

    "Perl makes the fun jobs fun
    and the boring jobs bearable" - me