my @bits = split(/\|/,$string); foreach my $bit(@bits){ # work with each bit.. }