in reply to Re: tab delimited extraction, formatting the output
in thread tab delimited extraction, formatting the output
#!/usr/bin/perl use strict; use warnings; my $file = "regular.txt.out"; open my $fh, "<", $file or die "Unable to open $file: $!"; my($u_value, $p_value, $mc_value) = (undef) x 3; while (my $line=<$fh>) { chomp $line; if ($line=~/\n\n\n/){ ($u_value, $p_value, $mc_value) = (undef) x 3; print "\n"; } elsif ($line=~/\bProcessing\s/) { $line=~s/\bProcessing\s\d+\.tx\.\d+: //; $u_value = $line; print "\n$u_value\n"; undef $p_value; } elsif ($line=~/\bPhrase/) { $line=~s/\bPhrase: //; $line=~s/\"//g; if ($p_value) { print "\n" . ' ' x length $u_value;} $p_value=$line; print "\t$p_value"; undef $mc_value; } elsif ($line=~/\s\s/ ) { if ($mc_value) { print "\n\t" . ' ' x length $p_value;} $mc_value=$line; print "\t$mc_value"; } else { } } close $fh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: tab delimited extraction, formatting the output
by hbm (Hermit) on Feb 16, 2009 at 21:34 UTC | |
by zzgulu (Novice) on Feb 16, 2009 at 23:15 UTC | |
by Anonymous Monk on Feb 17, 2009 at 14:00 UTC | |
by hbm (Hermit) on Feb 17, 2009 at 16:58 UTC | |
by zzgulu (Novice) on Feb 17, 2009 at 18:25 UTC | |
by hbm (Hermit) on Feb 17, 2009 at 14:20 UTC |