You could also read the filenames from STDIN while allowing to pass extra arguments via @ARGV like so:

#!/usr/bin/perl use strict; print "Info: ARGV is: @ARGV\n"; while (<STDIN>) { chomp; next if /^\s*$/; # skip empty lines if (-e $_) { # a regular file (might be suited to your needs) # do something with $_ as if it were shifted from @ARGV print "handling file: $_\n"; } else { warn "no such file: $_ \n"; } } __END__ usr@host:tmp> ls -1 file*.pl | fileabove.pl arg1 arg2 arg3 Info: ARGV is: arg1 arg2 arg3 handling file: fileabove.pl
It could be used i.e. this way:
ls -1 *.dat | fileabove.pl
or
fileabove.pl < filenames.txt
But finally it depends on your needs, which I might not have fully understood...
Update: Added the shebang-line to get rid of extra-calls to perl executable.


In reply to Re: Multiple file input into a perl script by Perlbotics
in thread Multiple file input into a perl script by kelder

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.