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;


item1 item2 item3 item4

Hope this helps!