in reply to Re: compare lines within a file
in thread compare lines within a file
Thanks for helping out with this I really appreciate the input from you guys.
I tried the above code but I get an error:
Use of uninitialized value in printf at parse_result.txt.pl line 23, <$fh> line 45.
The code I used was practically the same as yours except for changing the name of the input file to results.txt and changing the " " to "\t"
#!/usr/bin/perl use strict; use warnings; use Text::CSV; my @result; my $csv = Text::CSV->new ( { sep_char => '\t ' } ) # should set binar +y +attribute. or die "Cannot use CSV: ".Text::CSV->error_diag (); open my $fh, "<", "result.txt" or die "result.txt: $!"; while ( my $row = $csv->getline( $fh ) ) { if ($row->[0] =~ m{\QHWUSI-EAS95L_0025_FC:3:1:5232:1082#0//E}) { if (@result) { $result[1] = $row->[3]; } else { $result[0] = $row->[2]; } } } #printf "%s\t%s\n", @result; printf @result; $csv->eof or $csv->error_diag(); close $fh;
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: compare lines within a file
by garyboyd (Acolyte) on Mar 10, 2011 at 08:37 UTC | |
by kennethk (Abbot) on Mar 10, 2011 at 15:29 UTC | |
by garyboyd (Acolyte) on Mar 11, 2011 at 13:56 UTC | |
by kennethk (Abbot) on Mar 11, 2011 at 23:27 UTC | |
by garyboyd (Acolyte) on Mar 15, 2011 at 10:19 UTC | |
|