Next | Program Repair Shop | 255 |
s/// is for replacing complex strings and patterns
tr/// is for replacing all instances of one character with another
35 $_->[$i] =~ s/0/L/g; 36 $_->[$i] =~ s/1/H/g;
tr/// is even more appropriate here than usual:
$_->[$i] =~ tr/01/LH/;
In this case, it also makes the code smaller
Similarly $_->[$i] =~ tr/X/0/ instead of $_->[$i] =~ s/X/0/g
Next | Copyright © 2002 M. J. Dominus |