Hello all. I posted a message about pattern matching these days...
I want to change the values of "a" and "b" on the string below to "alabama" and "boston".
Jerry Latimer, on Perl cgi-list of Perl.com sugested to do this little simple code as follow:
$str = "(a**2) - (b**2) + 4*a*b";
$str =~ s/a/alabama/;
$str =~ s/b/boston/;
so, i would obtain: $str = "alabama**2)-(boston**2) + 4*alabama*boston, but i obtain
$str = "alabama**2)-(boston**2) + 4*a*b
The problem is code is just changing the fist "a" to "alabama", not all a's of the string. Can anyone help me? Thanks a lot.. Again!
I want to change the values of "a" and "b" on the string below to "alabama" and "boston".
Jerry Latimer, on Perl cgi-list of Perl.com sugested to do this little simple code as follow:
$str = "(a**2) - (b**2) + 4*a*b";
$str =~ s/a/alabama/;
$str =~ s/b/boston/;
so, i would obtain: $str = "alabama**2)-(boston**2) + 4*alabama*boston, but i obtain
$str = "alabama**2)-(boston**2) + 4*a*b
The problem is code is just changing the fist "a" to "alabama", not all a's of the string. Can anyone help me? Thanks a lot.. Again!