in reply to decoding pattern expression
Is there any way I can do it with bash scripting ?If you want bash scripting, you've come to the wrong site. If you'd like some help doing this with Perl scripting, I'd probably use indices 0-4 instead of A-E, make an array (my @values = (1, 7, 11, 3, 100)) and then split your coded strings:
my @terms = split //, $input; my $sum = 0; for my $i (0 .. @terms-1) { $sum += $values[$i] if $terms[$i] ne '?'; } print "$input = $sum\n";
#11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: decoding pattern expression
by AnomalousMonk (Archbishop) on Aug 22, 2014 at 15:19 UTC |