Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re^4: Capturing regex from map

by AnomalousMonk (Archbishop)
on Sep 14, 2013 at 10:30 UTC ( [id://1054086]=note: print w/replies, xml ) Need Help??


in reply to Re^3: Capturing regex from map
in thread Capturing regex from map

Not clean ...

... in part, perhaps, because the  @a input array is affected (via aliasing) and winds up 'oba-oba-obo-ed':

>perl -wMstrict -le "my @a = qw(foobar barfoo foobaz bar foobor); my @c = grep {s/fo(ob.).+/$1/} @a; ;; printf qq{'$_' } for @c; print qq{\n}; printf qq{'$_' } for @a; " 'oba' 'oba' 'obo' 'oba' 'barfoo' 'oba' 'bar' 'obo'

Replies are listed 'Best First'.
Re^5: Capturing regex from map
by Laurent_R (Canon) on Sep 14, 2013 at 13:40 UTC

    Yes, you are absolutely right, this is definitely one of the main reasons why it is not clean in my mind (and I upvoted your comment). But you can also make a temporary copy if you want to keep the original array intact, no big deal if the data is nor too large. But again, I am not suggesting this as a good solution. It might just be a possible useful alternative in some edge cases or very specific context, although I fail to see any.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1054086]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others scrutinizing the Monastery: (4)
As of 2024-03-29 14:06 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found