fjdb3 has asked for the wisdom of the Perl Monks concerning the following question:
I am a newbie to PERL but have a script that parses a tab delimited text file, and creates multiple text files from it, based upon the first 5 characters found in each line.
What I am trying to figure out is whether there is a way to ignore the first 5 characters in each line when I write each line from the source file into the appropriate log file.
The code that writes the data in the corresponding log is:This code works but includes the first 5 characters which were use to determine the appropriate LOG to write the line to.open(LOG, "$file"); while (<LOG>) { chomp($_); (@data) = split(/\t/, $_); (@zip) = split(//, $data[0]); $string = ""; for ($i=0; $i<=4; $i++) { # $string .= "$zip[$i]"; $string .= "substr($data[0], 7, 500)"; } # # match 1st 5 with the zip file # if ($z eq $string) { print NEW "$_\n"; } } close(LOG);
Thanks in advance for your noble assistance!
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: text file parsing with chomp
by toolic (Bishop) on Aug 12, 2009 at 20:21 UTC | |
|
Re: text file parsing with chomp
by ig (Vicar) on Aug 13, 2009 at 01:22 UTC | |
|
Re: text file parsing with chomp
by jethro (Monsignor) on Aug 12, 2009 at 21:02 UTC | |
by jwkrahn (Abbot) on Aug 12, 2009 at 21:08 UTC |