On Thu Jul 27 17:43:43 2006, stmpeters wrote: > On Tue Jan 15 00:10:56 2002, jamie wrote: > > This is a bug report for perl from jamie@shareable.org, > > generated with the help of perlbug 1.28 running under perl v5.6.0. > > > > > > ----------------------------------------------------------------- > > [Please enter your report here] > > > > I use the following code to generate file handles, as per the perlref > > manpage: > > > > local *FILE; > > open FILE, "<blahblah" or die "Error opening \`blahblah': $!\n"; > > return *FILE{IO}; > > > > For the most part, this has the same effect as returning *FILE, and > > seems cleaner. The perlref manpage seems to recommend this, although > > the perlfaq5 page seems to prefer the *FILE approach. > > > > Although this works fine with functions like `read', `write', > > `sysread' > > etc., it generates an unexpected result with `stat', `lstat' and the > > `-X' file test operators. > > > > Specifically, when one of these *FILE{IO} references is used in the > > file > > test functions, including `stat' and `lstat', it's converted to a > > string > > (i.e. "IO::Handle=IO(0x12345678)"), and that is used as the file name > > to > > test. > > > > On the other hand, when a typeglob *FILE is used in a file test > > function, the fstat() system call is used on the open file as > > expected. > > > > Is this a code discrepancy or something that should be documented in > > the > > perlfunc manpage? > > > > Cheers, > > -- Jamie Lokier > > > > Sorry about not responding to this earlier. This problem has been fixed > with change #28628. Except that change missed -t, -T and -B. So I’m reopening it. Is this something we can fix for 5.16? Is it possible that someone is relying on -T *$fh{IO} treating the ref as a file name? Also, that commits causes lstat(*$fh{IO}) to do the same thing as stat(_), but with a warning. Shouldn’t it revert to stat(*$fh{IO}, just as lstat(HANDLE) reverts to stat(HANDLE) (but with a warning)? -- Father Chrysostomos --- via perlbug: queue: perl5 status: resolved https://rt.perl.org:443/rt3/Ticket/Display.html?id=8244Thread Previous | Thread Next