[EMAIL PROTECTED] wrote: > > As I understand it, <> operator will open all items in @ARGV allowing > one to do a shell command line of > > perl.script file1 file2 file3 > > and inside perl.script you only need > > while (<>) { ... syntax to read all the files on the command line. > > <> will also open STDIN if the perl script is invoked from a pipe, such > as > > ls | perl.script > > So, 1. from within perl.script, how can one tell if the input stream is > coming from > STDIN or a file that was opened by <>? > > 2. If input stream is not coming from STDIN, but a file, how can one > tell which file is the current file (assuming multiple files were > specified on the command line)?
$ARGV will contain the name of the current file or '-' if reading from STDIN. $ perl -le'while (<>) {eof && print $ARGV}' test.txt test1.txt test.txt test1.txt $ perl -le'while (<>) {eof && print $ARGV}' < test.txt - $ cat test.txt | perl -le'while (<>) {eof && print $ARGV}' - John -- use Perl; program fulfillment -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>