Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re^2: difference in regex

by jwkrahn (Abbot)
on May 29, 2018 at 18:26 UTC ( [id://1215404]=note: print w/replies, xml ) Need Help??


in reply to Re: difference in regex
in thread difference in regex

what I would probably have done is to first split the string on a comma, then pop the last entry off the resulting array.

As in:

my @array = split /,/, $string; my $value = pop @array;

But you don't really need an array to do that because you can get the last value directly from the list that split returns:

my $value = ( split /,/, $string )[ -1 ];

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2024-03-29 13:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found