kevyt has asked for the wisdom of the Perl Monks concerning the following question:
ex: A1 changed to A2 A2 changed to A1 Thanks $m = "A1"; or $m = "A2"; This wont work: $m =~ tr(/1/2/ | /2/1/); This works, but I dont like it: if ($m =~ /1/){ $machine =~ s/1/2/g; } else{ $m =~ s/2/1/g; }
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: replace a digit with another digit
by davidrw (Prior) on Aug 17, 2005 at 18:46 UTC | |
by Transient (Hermit) on Aug 17, 2005 at 18:52 UTC | |
by davidrw (Prior) on Aug 17, 2005 at 19:01 UTC | |
by kevyt (Scribe) on Aug 18, 2005 at 13:45 UTC | |
by davidrw (Prior) on Aug 18, 2005 at 14:24 UTC | |
Re: replace a digit with another digit
by Transient (Hermit) on Aug 17, 2005 at 18:43 UTC | |
Re: replace a digit with another digit
by cowboy (Friar) on Aug 17, 2005 at 18:41 UTC | |
by davido (Cardinal) on Aug 17, 2005 at 19:21 UTC | |
by cowboy (Friar) on Aug 17, 2005 at 19:30 UTC |