You want to push onto an array all occurrences of OC\d+-\d+, right?

use Modern::Perl; my @found; while( <DATA> ) { chomp; push @found, m/(OC\d+-\d+)/g; } say $_ for @found; __DATA__ RTRV-PM-ALL:ADEL-OM3500-1:ALL:1898::,0-UP,NEND,,1-DAY,02-11,,;| ADEL-O +M3500-1 09-02-12 03:46:54 M 1898 COMPLD "OC192-11,OC192:CVS,0,COMPL,N +END,RCV,1-DAY,02-11,00-00,1" "OC192-11,OC192:ESS,0,COMPL,NEND,RCV,1-D +AY,02-11,00-00,1" "OC192-11,OC192:PSCW,0,COMPL,NEND,RCV,1-DAY,02-11,0 +0-00,1" "OC192-11,OC192:PSCP,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "O +C192-11,OC192:PSD,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-12,OC1 +92:CVS,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-12,OC192:PSCW,0,C +OMPL,NEND,RCV,1-DAY,02-11,00-00,1" > RTRV-PM-ALL:ADEL-OM3500-1:ALL:1898::,0-UP,NEND,,1-DAY,02-11,,;| ADEL-O +M3500-1 09-02-12 03:46:56 M 1898 COMPLD "OC192-12,OC192:PSCP,0,COMPL, +NEND,RCV,1-DAY,02-11,00-00,1" "OC192-12,OC192:PSD,0,COMPL,NEND,RCV,1- +DAY,02-11,00-00,1" "OC192-11-28,STS3C:CVP,0,COMPL,NEND,RCV,1-DAY,02-1 +1,00-00,1" "OC192-11-28,STS3C:UASP,0,COMPL,NEND,RCV,1-DAY,02-11,00-00 +,1" "OC192-11-28,STS3C:FCP,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC1 +92-11-145,STS3C:CVP,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11-1 +45,STS3C:ESP,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" "OC192-11-145,STS3 +C:SESP,0,COMPL,NEND,RCV,1-DAY,02-11,00-00,1" ;

Dave


In reply to Re: Find the array element as per the pattern. by davido
in thread Find the array element as per the pattern. by senthil_v

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.