in reply to Applying a regex to part of a string
Since substr returns an lvalue when less than four arguments are provided, you can do substitutions on portions of the string.
my $str = 'abracadabra'; substr($str, 3, 5) =~ s/a/@/g; print("$str\n"); # abr@c@d@bra
I realize this is off-topic, but it's a neat trick that's somewhat related.
|
|---|