http://www.perlmonks.org?node_id=997844


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!