The algorithm is that you value an A at 1, B at 2, C at 3, etc. Just add up the characters and you get your value. The following script demonstrates this process in action, and running it is most enlightening about the ways of the world.
#! /usr/bin/perl use strict; # Demonstration of how much various things are worth... # A=1, B=2, C=3... my %chr2val; my $chr_value = 1; for ('A'..'Z') { $chr2val{lc($_)} = $chr2val{$_} = $chr_value++; } my $value = 0; # Illustrative examples if people haven't entered their own. @ARGV = ("HARD WORK", "KNOWLEDGE", "ATTITUDE", "BULLSHIT") unless @ARG +V; foreach my $word (@ARGV) { my $value = 0; foreach my $char ($word =~ /\w/g) { $value += $chr2val{$char}; } print "The value of '$word' is $value%.\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: So *THAT* explains meetings!
by CubicSpline (Friar) on Oct 13, 2001 at 05:00 UTC | |
|
Re: So *THAT* explains meetings!
by Indomitus (Scribe) on Oct 13, 2001 at 01:53 UTC |