while(<>) { m/^(.+?\s+keyword=)(\d+)(\s+.+)$/ print "$1-" if $1; print "$2-" if $2; print "$3" if $3; print "\n"; }