my $a="command = adb asd 2t525 command=adfaf adsgadg asd "; my @t = map { "command" . $_ } grep { $_ ne "" } split /command/, $a; print @t;