perl -e "my $str='foo bar bat'; if ($str =~ /(foo) bar (bat)/ ) {print \"\$1: $1; \$2: $2)\"; }" $1: foo; $2: bat)