Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling

Re: Assign result of map to scalar variable

by runrig (Abbot)
on Jul 18, 2013 at 20:30 UTC ( #1045183=note: print w/replies, xml ) Need Help??

in reply to Assign result of map to scalar variable

Capturing parens return an array of the results, and you only have one set of capturing parens, so you can just return that:
my ($val) = map { /^\*\s\(?([^\)]+)\)?/} @GET_STRING; # Or (as others have suggested) my ($val) = map { /^\*\s\(?([^\)]+)\)?/ ? $1 : () } @GET_STRING;

Replies are listed 'Best First'.
Re^2: Assign result of map to scalar variable
by AnomalousMonk (Canon) on Jul 18, 2013 at 21:08 UTC
    my ($val) = map { /^\*\s\(?([^\)]+)\)?/} @GET_STRING;

    ++     Simplest by far... so far.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1045183]
[thezip]: What idiom should I use to determine that a directory is empty (for many directories)?
[thezip]: I suppose could check if readdir() returns other than '.' and '..', but that seems ugly.

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (9)
As of 2017-03-28 18:28 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (339 votes). Check out past polls.