Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: How to call a function on each item after a split?

by Kenosis (Priest)
on Oct 08, 2012 at 15:56 UTC ( #997844=note: print w/ replies, xml ) Need Help??


in reply to How to call a function on each item after a split?

Given your data set, another option is to use a regex to grab the items you want out of the string. Consider the following:

use strict; use warnings; my $str = "item1 | item2| item3 |item4|"; my @items = $str =~ /\w+/g; print "$_\n" for @items;

Output:

item1 item2 item3 item4

Hope this helps!


Comment on Re: How to call a function on each item after a split?
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (10)
As of 2015-07-30 19:22 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 (273 votes), past polls