indie_campbell has asked for the wisdom of the Perl Monks concerning the following question:
A and B can vary for any other letter. But each letter is associated with know value. I need to find what letters are presented then add up the values linked to them. Trying:# Title A 2 B
it works fine in this case, but if i was to change A to B in input, then the sum printed is wrong??if ( $_ =~ /^\S\s+\S+\s[\A\b]/) {$sum = 2} elsif ( $_ =~ /^\S\s+\S+\s[\B\b]/) {$sum = 2} # then for next letter if ( $_ =~ /^\S\s+\S+\s\S\s+[\B\b]/) {$sum += 1}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: regex problem
by kutsu (Priest) on Apr 09, 2004 at 19:23 UTC | |
by indie_campbell (Novice) on Apr 09, 2004 at 19:26 UTC | |
by Plankton (Vicar) on Apr 09, 2004 at 19:32 UTC |