How can I golf this Perl subroutine that does a substitution?
Posted
by JoelFan
on Stack Overflow
See other posts from Stack Overflow
or by JoelFan
Published on 2010-02-15T16:27:38Z
Indexed on
2010/04/25
5:43 UTC
Read the original article
Hit count: 153
perl
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?
© Stack Overflow or respective owner