use strict; use warnings; my $line = "one====two==three"; my ( $one, $two ) = grep { length > 0 } split /=/, $line; print "$one\n$two";