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


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

The split function can get rid of the white space also.

#!/usr/bin/perl use strict; use warnings; my $str = "item1 | item2| item3 |item4| "; print ">$_<\n" foreach split /\s*\|\s*/, $str;