in reply to Retriving Filename from Filehandle
Yes, it's possible on some systems (assuming the Perl file handle is associated with a system file handle). For example, the following works on (some?) Linux systems:
$ perl -e' open(my $fh, "<", "/etc/passwd") or die $!; my $fileno = fileno($fh); defined($fileno) or die "Not a file handle"; $fileno >= 0 or die "Not system file handle"; my $qfn = readlink("/proc/$$/fd/$fileno") or die $!; CORE::say $qfn; ' /etc/passwd
It would be better if your program tracked this itself, though.
Note that Perl provides $ARGV when reading from ARGV (e.g. using <>).
|
|---|