#!/usr/bin/perl use strict; use warnings; use feature qw(say); # perl -le "\$_='qwerty';s/r/print pos()/e;" my $str ='qwerty'; $str =~ s/[rq]/say pos($str); say $&;/eg; print "\t\$str: $str \n\n"; my $str0 ='qwerty'; $str0 =~ s/(r|q)/say pos($str0); say $&;/eg; print "\t\$str0: $str0 \n\n"; my $str1 ='qwerty'; $str1 =~ s/[rz]/say pos($str0); say $&;/eg; print "\t\$str1: $str1 \n\n"; my $str2 ='qwerty_erk'; $str2 =~ s/r/say pos($str2); say $&;/eg; print "\t\$str2: $str2 \n\n"; my $var='four'; $var =~ s/[fu]/say pos($var); say $&;/eg; print $var . "\n\n";