anniyan has asked for the wisdom of the Perl Monks concerning the following question:
Monks,
I have a very silly and simple question, but i dont understand why it works like this.
First while loop working properly whereas the second is not, why?
undef $/; open (FCMP, "anchor.txt") or die ("anchor.txt is not opened\n"); { local $/="\n"; while(<FCMP>) { print "$_\n"; chomp; @item = split(/\t/); $pii{$item[0]} = [$item[1], $item[2], $item[3]]; } } { local $/="\n"; while (<FCMP>) { my $an = $_; print "$an\n"; } }
The second while statement is not printing anything. So i thought that only one time a file handle can be used directly <FCMP> without assigning to a variable. Is it so? If wrong where am i going wrong.
Regards,
Anniyan
(CREATED in HELL by DEVIL to s|EVILS|GOODS|g in WORLD)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: File handle question
by Corion (Patriarch) on Aug 12, 2005 at 06:48 UTC | |
|
Re: File handle question
by Zaxo (Archbishop) on Aug 12, 2005 at 06:47 UTC | |
|
Re: File handle question
by hatter (Pilgrim) on Aug 12, 2005 at 12:15 UTC | |
|
Re: File handle question
by murugu (Curate) on Aug 12, 2005 at 09:23 UTC |