Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Separating array contents

by jnyman (Acolyte)
on Jun 07, 2013 at 08:53 UTC ( #1037635=note: print w/ replies, xml ) Need Help??


in reply to Separating array contents

Suggestion:
use 5.014; use Data::Dumper; my @arr = ('!', 'my', 'name', '!', 'is ', '!'); my $joined = join '' => map { s/^\s+|\s+$//g; $_ } @arr; $joined =~ s/^!|!$//g; my @result = split /!/ => $joined; say Dumper(@result);
This will handle the !-character in the beginning so that it won't generate an empty cell. It also trims the strings in the cells as in your description you had "is " -> "is". Update: improved trim regex

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (3)
As of 2016-06-27 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My preferred method of making French fries (chips) is in a ...











    Results (333 votes). Check out past polls.