tr/// (sometimes spelled y///, especially in code golf) works on characters specifically. m// (sometimes spelled //) works on regular expression matches, which may concern one or more characters (or in special cases zero, such as split //, $foo;).
Perl takes text very seriously. There is a load to know about processing text in Perl, but the basics are pretty quick to grasp. The full story is not complete without at least these manual pages, although for this specific topic the first few should suffice.:
- perlop (especially eq ne gt lt ge le cmp . x =~ .. )
- perlvar (especially $_ $1 $a $b $| $" $` $& $' $, $. $/ and $\ but especially especially $_ and $1
You might hope you never need to read perlebcdic, but there's that too.
|Replies are listed 'Best First'.|
Re^4: Syntax Perl Version support $c = () = $a =~ /\./g
by morgon (Priest) on Jul 18, 2018 at 00:09 UTC
by choroba (Cardinal) on Jul 18, 2018 at 00:13 UTC