use warnings; use strict; my $string="A111B111A111B111"; my $yes_or_no="no"; for (reverse(split //, $string)) { if ($_ eq 'A') { $yes_or_no = 'yes'; print "$_ yes_or_no=$yes_or_no\n"; last; } if ($_ eq 'B') { $yes_or_no = 'no'; print "$_ yes_or_no=$yes_or_no\n"; last; } }
In reply to Re^2: Change variable multiple times within a single string?
by GotToBTru
in thread Change variable multiple times within a single string?
by JTomb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |