$ cat splitter.pl use strict; use Data::Dumper; my $foo=qq(> abcd1234 abcd abcd >xyz123 xyz); $foo =~ s/\n//g; my @f = split(/[\>]/,$foo); $_ = '>' . $_ foreach @f; print Dumper(\@f); $ perl splitter.pl $VAR1 = [ '>', '> abcd1234abcd abcd ', '>xyz123 xyz' ];