How can I golf this Perl subroutine that does a substitution?

perl

Solution

This is how I would render that subroutine more idiomatically:

sub mySubst {
    (my $str = shift) =~ s|abc|xyz|ig;
    return $str;
}

Problem

I have the following subroutine in Perl to substitute "abc" for "xyz" in a string: ``` sub mySubst { my ($str) = @_; $str =~ s|abc|xyz|ig; return $str; } ``` It works, but seems way too verbose for Perl. How can I tighten it up?

Original source