http://qs1969.pair.com?node_id=151467


in reply to VVP:Perl oneliners for Unix commands

This should do the trick...

perl -e 'print $_,$/ for (<Q.PACES*>)'
___ Simon Flack ($code or die)
$,=reverse'"ro_';s,$,\$,;s,$,lc ref sub{},e;$,
=~y'_"' ';eval"die";print $_,lc substr$@,0,3;

Replies are listed 'Best First'.
Re: Re: Perl oneliners for Unix commands
by Kanji (Parson) on Mar 13, 2002 at 18:22 UTC

    If you use Perl's -l switch, you can simplify that further to just ...

    perl -le 'print for <Q.PACES*>'

        --k.


Re: Re: VVP:Perl oneliners for Unix commands
by petral (Curate) on Mar 13, 2002 at 19:40 UTC
    Right, this will work with the newest perls (>= 5.6), at least if you use glob() instead of <>.   The problem is:
    $ ls Hold/* |wc /bin/ksh: /usr/bin/ls: arg list too long 0 0 0 $ ls Hold |wc 169170 169170 2739945 $ perl -lwe'@x=<"Hold/*">;print 0+@x' 0 $ perl -lwe'@x=glob"Hold/*";print 0+@x' 169170 $
    Since 5.6 glob does not use a shell to expand filesystem wildcards.

    update:   Gah! tye, of course, is right <Hold/*> is the same as glob"Hold/*".   (No '"'s inside <>.)

      p

      The following are all the same:

      glob"Hold/*" glob("Hold/*") <Hold/*>
      but <"Hold/*"> is the same as glob('"Hold/*"'), which doesn't do what you want. I expected it to print 1 instead of 0 but it probably notes that there is no file named exactly Hold/* and so returns nothing.

              - tye (but my friends call me "Tye")