From: Naser Ali <mailto:[EMAIL PROTECTED]> wrote:
: Below is the actual code. This is just the preliminary code : to test the logic, it is not final yet, therefore, I am not : using "Warnings", "Strict" or for that matter anything else. Use strict and warnings from the very beginning. Don't wait while you're testing. I use them always. Even for the itty bitty scripts. : Also I am slurrping the whole file, and I know I do not have : to, but alternate ways, I ll decide later. There's nothing wrong with pulling in the whole file at once if you are certain the file size will remain small. : open(TFILE, "file.txt"); : @first=<TFILE>; : close (TFILE); : : : for ($i=0; $i <= $#first; $i++) { : : $Avg=$first[$i]; : chomp($Avg); : ($label,$TD,$YT,$M,$L,$Y,$W)= split (/\s+/,$Avg); : print "$label,$TD,$YT,$M,$L,$Y,$W\n"; : } That works fine. Perhaps file.txt is not opening or contains something you don't expect. Try this: use strict; use warnings; my $file = 'file.txt'; open FH, $file or die "Cannot open $file: $!"; my @averages = <FH>; close FH; foreach my $average ( @averages ) { chomp $average; my @fields = split ' ', $average; print " Bad line --> $average " unless @fields == 7; print join( ', ', @fields ), "\n"; } __END__ HTH, Charles K. Clarkson -- Mobile Homes Specialist 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>