Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
...the name of the perl script being executed is in $0 and the name of the input file can be easily extracted from @ARGV. But is there any way of getting at the output filename? E.g.perl process.pl input.txt > output.txt
I understand that under normal circumstances it is not possible to extract a filename from a filehandle - but if the name is being passed via the command line as here, is there (or should there be?) a convenient way of retrieving it?while (<>) { print "Reading from: $ARGV, Writing to: $???\n"; }
janitored by ybiC: Retitle from "Missing special variable?" for searchability
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Get filename of STDOUT
by Joost (Canon) on Aug 10, 2004 at 17:37 UTC | |
|
Re: Missing special variable?
by etcshadow (Priest) on Aug 10, 2004 at 17:52 UTC | |
|
Re: Get filename of STDOUT
by pelagic (Priest) on Aug 10, 2004 at 17:35 UTC | |
|
Re: Get filename of STDOUT
by gaal (Parson) on Aug 10, 2004 at 17:42 UTC | |
by eserte (Deacon) on Aug 10, 2004 at 18:05 UTC | |
by gaal (Parson) on Aug 10, 2004 at 18:23 UTC | |
by Ven'Tatsu (Deacon) on Aug 10, 2004 at 19:20 UTC | |
by gaal (Parson) on Aug 11, 2004 at 07:41 UTC | |
by ikegami (Patriarch) on Aug 10, 2004 at 20:21 UTC |