in reply to Re: Pattern Matching, left-to-right
in thread Pattern Matching, left-to-right

I don't know how 1 while s/// is clearer than s///g.

What's worse, it does not work correctly:

my %map = ( F => "|", S => "^", T => "&", R => "~", E => "\\" ); $_ = "\\E\\S\\"; s/\\([FSTRE])\\/$map{$1}/g; print "s///g: [$_]\n"; $_ = "\\E\\S\\"; 1 while s/\\([FSTRE])\\/$map{$1}/; print "1 while s///: [$_]\n"; __END__ s///g: [\S\] 1 while s///: [^]

\E\S\ gets translated to \S\, as per the OP's spec, but the 1 while s/// solution then blithely goes on to translate that as well. Oops.

(Note that there's a bunch of minor mistakes in your code. The last slash in your s/// is missing and (FSTRE) should be ([FSTRE]).)

Makeshifts last the longest.