>perl -wMstrict -le "for my $data (qw( Smith%John%BC142%Alberta Johnson%Andrew%AX321%Engineer )) { if($data =~ /.*%.*%A/) { my @arr = split('%', $data); print qq{$arr[0] $arr[1]}; } } " Smith John Johnson Andrew