A couple of map statements should make this pretty easy to do with an array:

my @array = map { chomp and $_ } <DATA>; my $want = 'Julia_Roberts'; my $change = 'Cintheia'; my ( $suffix ) = map { m/\A$want(\(\S+\))\z/smx and $1 } @array; my @final = map { ( /\A($change)\z/ and "$change$suffix" ) or $_ } @ar +ray if $suffix; warn Dumper \@final; __DATA__ Julia_Roberts(1,5) Cintheia Chelsia Rohan

The first map statement goes through the array and identifies the suffix for the pattern to be matched and the second applies the suffix to the desired element. I would probably do some kind of error checking after the first map, getting an array instead of a scalar from the map and checking to see if there's only one element returned -- what do you do if Julia_Roberts(1,5) and Julia_Roberts(2.8) are in the list?

perl -e 'split//,q{john hurl, pest caretaker}and(map{print @_[$_]}(joi +n(q{},map{sprintf(qq{%010u},$_)}(2**2*307*4993,5*101*641*5261,7*59*79 +*36997,13*17*71*45131,3**2*67*89*167*181))=~/\d{2}/g));'

In reply to Re: grep with multiple choice by agianni
in thread grep with multiple choice by sroy5

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.