[sf-perl] Perl in shell

Randal L. Schwartz merlyn at stonehenge.com
Mon May 14 11:15:25 PDT 2007


>>>>> "David" == David Alban <extasia at extasia.org> writes:

David> I write perl rather than shell when I have the choice, but I don't
David> think embedding perl in shell is necessarily a bad thing.

David> It's not difficult to use shell variables in perl.  For example:

David>   #!/bin/bash

David>   var=foo

David>   perl -e '
David>     my $var = q{'"$foo"'};
David>     print "$foo\n";
David>   '

Or just:

   var="something arbitrarily complex"
   export var

   perl -e '
        $var = $ENV{var};
        ...
   '

No fancying quoting required. :)

-- 
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<merlyn at stonehenge.com> <URL:http://www.stonehenge.com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!


More information about the SanFrancisco-pm mailing list