I am trying to read a file. The file contents can be either STDIN or a file name.
When it is from a file, I open as follows.
Otherwise if it is from STDIN, I always use
Now my constraint is the user can either specify the file name or pipe as STDIN from another program. How to handle that situation in the same script?
My perl program has the usage as below.
Perl converter.pl --in file <filename or STDIN> --out file <out filename>
Please let me knowhow to handle this. Thanks.
When it is from a file, I open as follows.
Code:
Open filename ($filename)
While(<$filename>){
#process each line
}
Code:
while(<>){
#process each line
}
My perl program has the usage as below.
Perl converter.pl --in file <filename or STDIN> --out file <out filename>
Please let me knowhow to handle this. Thanks.
Comment