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