[Chicago-talk] Piping a command into perl?

Randal L. Schwartz merlyn at stonehenge.com
Sat Mar 18 22:40:00 PST 2006

>>>>> "Jay" == Jay Strauss <me at heyjay.com> writes:

Jay> Here is exactly what I'm doing:
Jay> #!/bin/bash

Jay> . tws.setup # this does a whole bunch of setup for the current shell

Jay> perl -e '
Jay>     my @a = <*.jar>;
Jay>     print join ":", grep { !/jtsclient|Guide/ } (map { s/\//./g; $_ } @a);
Jay> '

Jay> #   When you run this script it produces a line like below to STDOUT
Jay> #
Jay> #   jcommon-1.0.0.jar:jfreechart-1.0.0.jar:jhall.jar:jts.jar:other.jar:rss.jar
Jay> #

Jay> What I have works, I just thought I'd put the perl into a heredoc and
Jay> make it prettier

Then put it into a heredoc, and make it prettier:

    . tws.setup
    perl <<'END_OF_PERL_SCRIPT'
        my @a = <*.jar>;
        print join ":", grep { !/jtsclient|Guide/ } (map { s/\//./g; $_ } @a);

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 Chicago-talk mailing list