[Chicago-talk] Piping a command into perl?

Jay Strauss me at heyjay.com
Sun Mar 19 10:33:38 PST 2006


On Sunday 19 March 2006 12:40 am, Randal L. Schwartz wrote:
> >>>>> "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:
>
>     #!/bin/bash
>     . tws.setup
>     perl <<'END_OF_PERL_SCRIPT'
>         my @a = <*.jar>;
>         print join ":", grep { !/jtsclient|Guide/ } (map { s/\//./g; $_ }
> @a); END_OF_PERL_SCRIPT

thanks Randal.  I didn't realize I needed the single quotes around 
END_OF_PERL_SCRIPT. 

thanks again
Jay


More information about the Chicago-talk mailing list