Perl offers this very nice feature:
while ( <> )
{
# do something
}
…which allows the script to be used as script.pl <filename> as well as cat <filename> | script.pl.
Now, is there a way to determine if the script has been called in the former way, and if yes, what the filename was?
I know I knew this once, and I know I even used the construct, but I cannot remember where / how. And it proved very hard to search the ‘net for this (“perl stdin filename”? No…).
Help, please?
The variable
$ARGVholds the current file being processed.