Here is a sample of the text I am trying to parse:
Well I want to read a text file wiht this information, then place each tab separated item into a separate part of the array so I can do some work, then dump it out with all the without any extra tabs. Right now I get the text I need, but with a bunch of extra tabs and other informatio I would rather not have.Berlinda Girl Newmarket Lord, army; shield 54 + Soccer Berlindis Girl Newmarket Lord, army; shield 32 + Football
Here is my code:
ProcessRedFile(); sub ProcessRedFile { open (READ, "dump.txt"); $Counter=(); open (OUT, ">/Users/simondyates/Desktop/OutFile.txt"); @File =<READ>; foreach $File(@File) { @Format = split(/ *\s\s */,$File); push (@Finish, @Format); } } $x=0; print OUT "\t"; $x=0; while ($x<200) { @Test = split(/\t/,$Finish[$x]); push (@Test2, @Test); $x++; } @Finish = @Test2; while ($x<200) { if ($f eq 1) { print OUT "$Finish[$x]\t"; } elsif ( $f eq 2) { print OUT "$Finish[$x]\t"; } elsif ( $f eq 4) { print OUT "$Finish[$x]\t"; } elsif ( $f eq 5) { print OUT "$Finish[$x]\t"; } elsif ( $f eq 8) { print OUT "\n"; $f=0; } $x=$x+1; $f++; } close READ; close OUT;
In reply to Parsing simple text, made difficult by sdyates
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |