Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
My program takes in any number of files including a '-' or none which would then read from STDIN. The problem is, i'm doing something like so:
I'd like to be able to just make FILE equal STDIN before so i don't have to fiddle around with anything in the condition of the loop. (Unless it happens to be really nice and simple to do it in the condition).foreach $file (@files) { if ((!open (FILE, "<file")) && ($file ne '-')) { #print error and die } else { while ($line = <FILE>) #OR if FILE is undefined then <STDIN> { #do something } } }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Equate File Handles?
by ikegami (Patriarch) on May 07, 2009 at 02:58 UTC | |
|
Re: Equate File Handles?
by Anonymous Monk on May 07, 2009 at 02:39 UTC |