in reply to Re: check scalar holds filehandle
in thread check scalar holds filehandle
but that doesn't work for ram file handles.is not fileno ($mem) == -1 the right way to tell if an handle is opened onto a memory file? and reliably be sure that is an handle anyway? The only minus is that for memory filehandle we cant be sure they point to the same point because they all returns -1.
so you dont need tell to tell!# real file perl -Mstrict -wE "open my $fh,'<','out.log' or die;say fileno($fh) ? +'FileHandle! '.fileno($fh):'NA'" FileHandle! 3 # memory file perl -Mstrict -wE "open my $fh,'<',\my $mem or die;say fileno($fh) ? ' +FileHandle! '.fileno($fh):'NA'" FileHandle! -1 # not existing file, closed filehandles, aliens things.. perl -Mstrict -wE "open my $fh,'<','out.logXX';say fileno($fh) ? 'File +Handle! '.fileno($fh):'NA'" NA
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: check scalar holds filehandle
by BrowserUk (Patriarch) on Oct 30, 2015 at 09:16 UTC | |
|
Re^3: check scalar holds filehandle
by afoken (Chancellor) on Oct 31, 2015 at 07:57 UTC |