Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Separating array contents

by johngg (Abbot)
on Jun 07, 2013 at 17:27 UTC ( #1037717=note: print w/ replies, xml ) Need Help??


in reply to Separating array contents

If there is no trailing delimiter, as in your posted text, you can do this:-

$ perl -Mstrict -Mwarnings -E ' my $str = q{!one ! two!three and four! five}; my @arr = reverse map { scalar reverse } split m{\s*!\s*}, scalar reverse $str; say qq{>$_<} for @arr;' >one< >two< >three and four< >five< $

If there is a trailing delimiter then you will still have the problem of an empty leading element so there would be no advantage to using this.

I hope this is of interest.

Cheers,

JohnGG


Comment on Re: Separating array contents
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (15)
As of 2015-07-06 17:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (77 votes), past polls