First of all, I'm not even sure split() is the best way to do this. I just started learning Perl two weeks ago, so I apologize if I seem silly. I have data that look like this:
1xny_01 PROPIONYL-COA CARBOXYLASE COMPLEX B -0.8192 A A A 1xqd_00 CYTOCHROME P450 55A1 -46.5601 A B A
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:
while ($line = <FILE>) { chomp; ($a, $b, $c, $d, $e, $f, $g, $h) = split (/\s+/,$line);
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?

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 ] ; }

In reply to ignore some delimiters while using split by nurulnad

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.