nurulnad has asked for the wisdom of the Perl Monks concerning the following question:
What I need to do is read each line, compare the last three characters (e.g. A A A) and output the line if they are the same. I figured I'd store each of these as separate entities so I used split () in this way:1xny_01 PROPIONYL-COA CARBOXYLASE COMPLEX B -0.8192 A A A 1xqd_00 CYTOCHROME P450 55A1 -46.5601 A B A
and I figured I could do something like if $f=$g=$h, then output the line that returns that as true. but the problem is PROPIONYL-COA CARBOXYLASE COMPLEX B is stored as 4 characters while CYTOCHROME P450 55A1 is stored as 2 charaters. How can I set them to be read as a single string? or if split is not the best way, can you suggest any other way to do this?while ($line = <FILE>) { chomp; ($a, $b, $c, $d, $e, $f, $g, $h) = split (/\s+/,$line);
EDIT: Thank you for the replies, everyone! What I did was simply this:
while ($line = <FILE_NEW>) { chomp; ($a, $b, $c) = (split /\s+/,$line) [ -1,-2,-3 ] ; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: ignore some delimiters while using split
by JavaFan (Canon) on Aug 13, 2010 at 00:49 UTC | |
|
Re: ignore some delimiters while using split
by BrowserUk (Patriarch) on Aug 13, 2010 at 00:50 UTC | |
by MajingaZ (Beadle) on Aug 13, 2010 at 01:33 UTC | |
by AnomalousMonk (Archbishop) on Aug 13, 2010 at 10:19 UTC | |
|
Re: ignore some delimiters while using split
by roboticus (Chancellor) on Aug 13, 2010 at 01:58 UTC | |
|
Re: ignore some delimiters while using split
by shawnhcorey (Friar) on Aug 13, 2010 at 01:52 UTC | |
|
Re: ignore some delimiters while using split
by AnomalousMonk (Archbishop) on Aug 13, 2010 at 10:33 UTC | |
|
Re: ignore some delimiters while using split
by perlpie (Beadle) on Aug 14, 2010 at 21:59 UTC |