in reply to Re: Weird substitution, missing output
in thread Weird substitution, missing output
my %sub = { ">" => "\t\t++k;\n", "+" => "\t\t++*k;\n", ... # fill as needed }
The hash initialization statement above should use parentheses and not curlies:
my %sub = ( ... );
s/(.)/$sub{$1}/ge
Also note that the /e modifier is not needed in this substitution (although it does no harm except to burn some time) because $sub{$1} is already a scalar that can be interpolated into a string.
Give a man a fish: <%-{-{-{-<
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Weird substitution, missing output
by Anonymous Monk on May 10, 2019 at 20:06 UTC |