Open p5pRT opened 24 years ago
othersideofthe:simon ~ % perl -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH; };
0 while <$f>; print $.'
48
othersideofthe:simon ~ % perl -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
0 while <$f>; print $.'
Use of uninitialized value in print at -e line 1.
othersideofthe:simon ~ % perl -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
$a=$. while <$f>; print $.'
48
This appears to have gotten worse.
> othersideofthe:simon ~ % perl -wle 'my $a;
> my $f=do { local *FH; open(FH,"/etc/passwd"); *FH; };
> 0 while <$f>; print $.'
> 48
[~] perl5.6.2 -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH; };
0 while <$f>; print $.'
28
[~] perl5.8.6 -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH; };
0 while <$f>; print $.'
readline() on unopened filehandle FH at -e line 3.
0
> othersideofthe:simon ~ % perl -wle 'my $a;
> my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
> 0 while <$f>; print $.'
> Use of uninitialized value in print at -e line 1.
[~] perl5.6.2 -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
0 while <$f>; print $.'
Use of uninitialized value in print at -e line 3.
[~] perl5.8.6 -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
0 while <$f>; print $.'
Use of uninitialized value in print at -e line 3.
> othersideofthe:simon ~ % perl -wle 'my $a;
> my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
> $a=$. while <$f>; print $.'
> 48
[~] perl5.6.2 -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
$a=$. while <$f>; print $.'
28
[~] perl5.8.6 -wle 'my $a;
my $f=do { local *FH; open(FH,"/etc/passwd"); *FH{IO}; };
$a=$. while <$f>; print $.'
28
@simoncozens, thank you for reporting Perl RT 2566. Your ticket has been moved to https://github.com/Perl/perl5/issues/1420
This appears to still be an issue on perl 5.30. $.
is not set if you do <$f>
where $f
was assigned from *FH{IO}
This appears to still be an issue on perl 5.30. $. is not set if you do <$f> where $f was assigned from *FH{IO}
This can also be formulated as «$^LAST_FH is not set if you do <$f> where $f was an IO
reference instead of a glob reference»
This appears to still be an issue on perl 5.30. $. is not set if you do <$f> where $f was assigned from *FH{IO}
This can also be formulated as $^LAST_FH is not set if you do <$f> where $f was an
IO
reference instead of a glob reference
It's not so much that it's not set, it's that it's set and then immediately cleared.
Each of the I/O ops either has a rv2gv generated for it (most) or calls rv2gv itself (readline), which for an IO ref create a mortal GV which is then assigned to PL_last_in_gv, on the next FREETMPS that's released and PL_last_in_gv is cleared (in Perl_sv_clear()).
Migrated from rt.perl.org#2566 (status was 'open')
Searchable as RT2566$