Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Save Split to Array

by bv (Friar)
on Aug 27, 2009 at 16:39 UTC ( [id://791715]=note: print w/replies, xml ) Need Help??


in reply to Save Split to Array

Your problem seems to be understanding split. Any part of your string that matches the regular expression argument will be removed -- only the remaining parts populate the returned array.

my $string = "This word:ding, is:a sound."; $,='!'; #prints "This!word:ding,!is:a!sound." print split( /\s/, $string ); #prints "This word!ding, is!a sound." print split( /:/, $string ); #prints "Th! word:ding, !:a sound." print split( /is/, $string);
$,=' ';$\=',';$_=[qw,Just another Perl hacker,];print@$_;

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (6)
As of 2024-04-26 09:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found