K8VWO has asked for the wisdom of the Perl Monks concerning the following question:

When using a command line:
perl -ne "print $_ if m:xxx: && (m:yyy: || m:zzz: )" input.txt
Is it possible to specify a wildcard list of files? Or pipe the result of a ls/dir command to it? Thanks...

Replies are listed 'Best First'.
Re: Command line multiple file input
by osunderdog (Deacon) on Dec 15, 2004 at 15:22 UTC

    Since you reference dir I assume that you're running windows. If that is true then the answers are NO and YES. This isn't a Perl problem, it's a brain dead windows shell problem.

    For example on Windows XP,

    perl -e "print join(',', @ARGV)" *.*

    Yields:

    *.*

    On Linux, the sample command produces:

    argo.user.properties,.....more files....,tmp

    To do what you want to do, glob will probably help.

    perl -e "print join(',', glob(shift))" *
    On windows this then produces:
    argo.users.properties,.....more files......,tmp

    Hope that helps


    "Look, Shiny Things!" is not a better business strategy than compatibility and reuse.


    OSUnderdog
Re: Command line multiple file input
by dragonchild (Archbishop) on Dec 15, 2004 at 14:00 UTC
    What's happened when you tried input.* or something similar?

    I generally do something like perl -pi -e 's/foo/bar/g' *.pm ... YMMV

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re: Command line multiple file input
by Anonymous Monk on Dec 15, 2004 at 14:11 UTC
    The answers are, 'yes' and 'yes'.

    Since you asked, you apparently tried to do this, and failed. What did you try?