Guys, you look experts at this :-)
RGS> IHMO, the right way to fix this is
RGS> - to add a private op flag to OP_READLINE to indicate
RGS> that the readline() syntax was used instead of <>.
RGS> - to change ck_null to ck_fun in opcode.pl as you did.
RGS> - to modify ck_fun to check for this flag, and do nothing
RGS> if it's not present.
RGS> Also, the op corresponding to readline($fh) should have an OPf_SPECIAL
RGS> flag, just like <$fh> does.
RGS> And while we're at it, make readline() without arguments equivalent
RGS> to readline(*ARGV).
Once you're looking at all these things, you probably could have a
look at the following troubles (item 1 is like a value of 100
2 and 3 have a value around 7 to me) :
1) ----[ID 20020222.011])-----
while(<>){ print $.,'. ',$_; close ARGV if eof; eof(); }
is equivalent to-----
my $f;
do{
$f=0;
while(<>){
$f = 1;
print $.,'. ',$_;
if (eof){
close ARGV;
}
}
}while($f);
-------------------------------------------------------------------
Looks like eof() after close ARGV somehow resets the while(<>) operator
and the latter starts all over again.
Since by that moment the @ARGV is empty, it starts reading '-'..
If only the eof() status that has been detected in the call to eof()
could be saved in the while(<>), so that the loop would bail out...
2) ----[Failed to report via perlbug@perl.org, the server does not
confirm the receipt of my message, so no bug id]-----
The tests are in the attached.
The thing is all bout doing close ARGV; inside a while(<>) or its
hand-made analog. Quite puzzling to me, but of a moderate importance.
3) ----question on open FH, '-' -------
open FH, '-' behaves neither
like '<&=STDIN' nor like '<=' should behave:
open STDIN,'<'.$0;
open V,'-';
close V;
while(<STDIN>){print}; #prints the source
open STDIN,'<'.$0;
open V,'-';
close STDIN;
while(<V>){print}; #does not
Is this as expected? Is this documented anywhere?
- Regares, with _great respect_ :) and TIA
- Anton
Thread Previous
|
Thread Next