Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (1)
As of 2022-11-26 09:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?