Your problem is that you are trying to split on the file specified on the command line since your are splitting the diamond operator (<>). This forces a new read of the file (hence skipping a line). In your case, try splitting on $_ instead. Also, I suggest that you enable warnings (-w) and use strict. These will save you many hours of heartbreak in the long-run. Here's a slight clean-up of your code:
#!/usr/bin/perl -w use strict; my @chunks; open(LIST, ">newlist.lst") or die; #the new classlist select(LIST); #select the newlist for output while (<DATA>) { @chunks = split(/\",\"/ , $_); #split the lines at "," print $chunks[5] , " , " , $chunks[6] ," , ", $chunks[7]," , , , " +,$chunks[4] ," , ", $chunks[4] , " , , " ,unpack("A1",lc($chunks[7])) +,lc($chunks[6]), "\n"; } close(LIST); #we're done!
Cheers,
Ovid
Update: Of course, once again I post only to see that someone else got there first. I really need to remember to check that.
In reply to (Ovid) Re: every other line?
by Ovid
in thread every other line?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |