Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
The stupid question is the question not asked
 
PerlMonks  

Re: Capturing regex from map

by BrowserUk (Pope)
on Sep 13, 2013 at 16:38 UTC ( #1053965=note: print w/ replies, xml ) Need Help??


in reply to Capturing regex from map

but I am wondering if this is not desirable for some reason.

Why are you wondering that? If it is working for you; what makes you think it might be "not desirable"?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.


Comment on Re: Capturing regex from map
Re^2: Capturing regex from map
by trippledubs (Scribe) on Sep 13, 2013 at 17:11 UTC
    Well possibly I was thinking that it has only worked "so far" and that some landmine is potentially waiting, since I haven't seen that construct elsewhere. I'm not exposed to a lot of code though so I usually suspect any original thought is either not original or wrong for some reason I haven't thought of. I usually see something like
    my ($match_1,$match_2) = ($string =~ /(.*):(.*)/) // And in my own scripts I'm using constructs like my ($wanted_service) = (map { /^online.*svc:(.*?):/ } `svcs`)[15];
    Someone asked me, what is the best way to do x, I reach for the handy regex mapper, but I'm not sure it is the best. In sum: lack of confidence and the competitive drive for perfection. AND to a smaller degree, I want more xp. Why did you wonder why I wondered? This might go on all day, maybe I'll level up! :)
      Why did you wonder why I wondered?

      Because most times when this kind of question -- someone second guessing a piece of working code -- comes up, there is usually some clue, either in the post, or in the history of this place, to indicate what the fear that underlies the question is.

      With your question I detect nothing that indicates either a commonly frowned upon, but otherwise workable construct -- as we often see with map in a scalar or void context for example -- nor anything in your post to indicate the basis of your doubts.

      I cannot see any reason not to use the construct for those occasions when it does the required task. It is concise and to my eyes clear. But, there is the possibility that I'm missing something, hence I wanted to know more ...


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        > It is concise and to my eyes clear.

        well, as you can see from some answers it's not clear for everybody.

        you are using the fact that 'm//' in list context returns a list of the grouped matches (if any).

        (w/o grouping it returns 1 for true matches)

        If you are using this idiom very often you might want to document it for other maintainers...

        Cheers Rolf

        ( addicted to the Perl Programming Language)

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (4)
As of 2014-04-21 02:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    April first is:







    Results (489 votes), past polls