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