On Wednesday 18 July 2007 17:08, Joseph L. Casale wrote:
> Is that true?
> I use while loops and they cycle through each line without me keeping
> track? jlc

Yeah, it's true. Why would you want to keep track?
(you can BTW, look at perldoc perlvar for $.)

in my code, the 1st line is written into $prev. This code will fail if there's 
only one line in the input file as the look would never be entered.

The ($this=<MYFILE>) reads from MYFILE putting the line into $this. The whole 
expression then returns the result. If it's worked it returns true and the 
loop is executed. If it fails it returns false and the loop exits.

Loosely speaking anyway

Gary

>
> -----Original Message-----
[snip]
> Hi Ayesha
>
> you need to only read once per line, but remember the last one.
>
> $prev=<MYFILE>
> while ($this=<MYFILE>) {
>   print "$prev and $this\n";
>   $prev=$this;
> }
>

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000     

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to