AllPaoTeam has asked for the wisdom of the Perl Monks concerning the following question:
Good morning Monks, Im fairly new to Perl, I get an output file from a software which is a text file seperate by tabs(although some tabs look longer than others). I can also send an edited version of the file if someone needs the actual file to work with. Here is the code I am using to parse it:
# Opens file $file3 = "c:\\users\\plor\\desktop\\Presc_count2.txt"; $file4 = "c:\\users\\plor\\desktop\\Presc_count3.txt"; open INPUT2, ">", $file4 or die $!; open OUTPUT2, "<", $file3 or die $!; while ($t2 = <OUTPUT2>) { @lines = split /s+/, $t2; print "$lines[0],$lines[1]\n"; } } close(OUTPUT2); close(INPUT2);
When I try to print to test "$lines[0], $lines1" it doesn't give me the output I was expecting, I would've thought it would give me the first two words on that line, instead it prints out either a blank space or nothing(i cant tell if its a space or not). I also tried using split with ('\t') also and I get the same result. Basically I just want each word stored in an element of an array so I can manipulate it. Thanks in advance for any knowledge you guys can pass down to me. -Pao
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Extracting from output file
by Athanasius (Archbishop) on Aug 15, 2014 at 16:35 UTC | |
by AllPaoTeam (Sexton) on Aug 15, 2014 at 16:47 UTC | |
by Athanasius (Archbishop) on Aug 15, 2014 at 16:58 UTC | |
|
Re: Extracting from output file
by AppleFritter (Vicar) on Aug 15, 2014 at 18:01 UTC | |
by AllPaoTeam (Sexton) on Aug 15, 2014 at 18:45 UTC | |
by AppleFritter (Vicar) on Aug 15, 2014 at 20:05 UTC |