[comp.lang.perl] extracting a script from a mail/article

stef@zweig.sun (Stephane Payrard) (08/14/90)

    Howdy,

I have yet to see a perl switch which allows to save a perl script
part of other informations... as opposed to -x which executes the
script.  Here is a script which does just that... to be extracted with
'perl -x' (for kicks). perl 3.0 patch level 27 required.

Feed 'perl -x > filename' with the contents of this article to save
the script in the file filename. Make the saved script executable.
Piping a mail/article with the saved script gives you the embedded
script on sdtout.  It assumes that there is only one perl-script
embedded (ie: the current article does not match this definition).



#! /usr/bin/perl -n
(/^#!/../^__END__/ )&& print $_;
__END__
#! /usr/bin/perl -n
(/^#!/../^__END__/ )&& print $_;
__END__


        stef
--
Stephane Payrard -- stef@sun.com -- (415) 336 3726
Sun Microsystems -- 2550 Garcia Avenue --  M/S 10-09 -- Mountain View  CA 94043