in reply to parsing data from file

It is not clear at all what problem you are facing... your code could be simplified, but it is mostly ok. Are you getting any errors? What is it that you want help with? In the meantime, here are a few code-cleanup suggestions

# chop the inputs to remove the trailing \n my $l = <STDIN>; chop($l); .. and so on.. # use while to loop over the lines in the file open MAPFILE "$sdtfile" or die; while (<MAPFILE>) { my ($date, $time, $lot, $waf, $ts, $sstep, $machine, $prog, $product +, $plnfile, $striping) = split(/,/, $_); if (..) { # rest of the program } }
--

when small people start casting long shadows, it is time to go to bed

Replies are listed 'Best First'.
Re^2: parsing data from file
by ikegami (Patriarch) on Oct 16, 2005 at 03:03 UTC

    ack! why use chop when you can use the safer chomp? And how come neither was used inside the while (<MAPFILE>)? Finally, why did you remove the call to lc?

    # chomp the inputs to remove the trailing \n chomp(my $l = <STDIN>); . . . # 3-arg open safer. # No use putting quotes around $sdtfile. open(MAPFILE, '<', $sdtfile) or die("Unable to open map file: $!\n"); # No need to load whole file in memory. # Use while instead of foreach. while (<MAPFILE>) { my ( $date, $time, $lot, $waf, $ts, $sstep, $machine, $prog, $product, $plnfile, $striping, ) = map lc, split(/,/, $_); if (...) { . . . } }