Re: Reading file issue
- From: Keith Keller <kkeller-usenet@xxxxxxxxxxxxxxxxxxxxxxxxxx>
- Date: Thu, 28 Feb 2008 13:44:53 -0800
On 2008-02-28, sharon@xxxxxxxxxxxxxxxxxxx <sharon@xxxxxxxxxxxxxxxxxxx> wrote:
I have an issue that puzzles me, I f anyone can point me to the
documentation it will be great.
I'm writing a file and reading it right after. the results I'm getting
from reading the file are different then what I expect.
This is not a very clear error description. Are you sure the file
contains what you want? Perhaps you have written out the wrong data,
and reading it back is working fine. (In this case that's not true, but
you need to specify what's broken, and how you know.)
#!/usr/bin/perl
use strict;
use warnings;
while (<NewSCAL>){
my $line = <NewSCAL>;
print $line;
}
This loop is reading a line from NewSCAL, discarding it, reading the
next line and putting it into $line, printing it, then redoing the loop
till the lines are exhausted. So you're discarding every other line.
The idiomatic way to write your loop is
print while <NewSCAL>;
If you wish to process each line somehow, you'd do
while (my $line=<NewSCAL>)
{
# do stuff to $line, including possibly printing it
}
the results are:
[over 1100 lines snipped]
Don't do that! Post *example* inputs and/or outputs which replicate
your problem. Please read the Posting Guidelines which are posted here
quite frequently.
--keith
--
kkeller-usenet@xxxxxxxxxxxxxxxxxxxxxxxxxx
(try just my userid to email me)
AOLSFAQ=http://www.therockgarden.ca/aolsfaq.txt
see X- headers for PGP signature information
.
- References:
- Reading file issue
- From: sharon
- Reading file issue
- Prev by Date: Reading file issue
- Next by Date: Re: Help with script
- Previous by thread: Reading file issue
- Index(es):
Relevant Pages
|
|