in reply to Re: Change variable multiple times within a single string?
in thread Change variable multiple times within a single string?
Hi hdb,
Your solution would not only either set/reset and print the value 'yes' and 'no' for 'A' and 'B', but would also do for subsequent '1' also. And such that either 'yes' or 'no', were printed when the value of '1' is seen.
Though, the OP wanted 'yes' or 'no', for 'A' and 'B'.
So, I added this next if /1/; like so:
Though the OP didn't give any information on what he expect when '1' is seen.for (split //, $string ) { next if /1/; $yes_or_no = $decision{$_} if exists $decision{$_}; print "$_ ($yes_or_no)\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Change variable multiple times within a single string?
by hdb (Monsignor) on Apr 27, 2013 at 16:38 UTC | |
by 2teez (Vicar) on Apr 27, 2013 at 18:09 UTC |