Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
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 studying the Monastery: (16)
As of 2014-07-28 17:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (204 votes), past polls