Re: Understanding split in a while loop

2005-02-28 Thread Gavin Henry
On Monday 28 Feb 2005 18:34, John W. Krahn wrote: > Gavin Henry wrote: > > Hi all, > > Hello, > > > Just a quickie. I think the answer is that th while loop is going through > > the file twice? > > > > -- > > Codes that does what I expect, i.e. prints out the 42 lines of my passwd > > f

Re: Understanding split in a while loop

2005-02-28 Thread John W. Krahn
Gavin Henry wrote: Hi all, Hello, Just a quickie. I think the answer is that th while loop is going through the file twice? -- Codes that does what I expect, i.e. prints out the 42 lines of my passwd file, with the array spaces, due to the array in "", swapped for and runs on $_: #!/us

Re: Understanding split in a while loop

2005-02-28 Thread Jenda Krynicky
From: "Gavin Henry" <[EMAIL PROTECTED]> > Just a quickie. I think the answer is that th while loop is going > through the file twice? Nope > -- > Codes that does what I expect, i.e. prints out the 42 lines of my > passwd file, with the array spaces, due to the array in "", swapped >

Re: Understanding split in a while loop

2005-02-28 Thread Gavin Henry
-- Just getting into the best language ever... Fancy a [EMAIL PROTECTED] Just ask!!! >> >> >>I am not sure why? It misses the odd ones. >> >>while () { >>my @passwds = split /:/, ; >> > You are reading the file twice in each while loop. Whenever you access > , it returns a line and moves to the

Re: Understanding split in a while loop

2005-02-28 Thread Ankur Gupta
I am not sure why? It misses the odd ones. while () { my @passwds = split /:/, ; You are reading the file twice in each while loop. Whenever you access , it returns a line and moves to the next line of the file. So in "while () {" it returns one line of the passwd file . As you are reading the l

Understanding split in a while loop

2005-02-28 Thread Gavin Henry
Hi all, Just a quickie. I think the answer is that th while loop is going through the file twice? -- Codes that does what I expect, i.e. prints out the 42 lines of my passwd file, with the array spaces, due to the array in "", swapped for and runs on $_: #!/usr/bin/perl use strict;