Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
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 browsing the Monastery: (9)
As of 2014-10-20 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (92 votes), past polls