in reply to Search for abcNUMBERdef, make it a variable, then do math?
#!/usr/bin/perl use warnings; use strict; my %nums; @nums{qw(today yesterday this last)} = undef; my $alts = join('|',keys %nums); while (<DATA>) { /($alts)(\d+)\1/; $nums{$1} = $2; } for my $key (keys %nums) { my $ans = ($nums{$key} * 0.4)/100; print "$key: $ans (from $nums{$key})\n" } __DATA__ Today: today408today Clicks: 34 Yesterday: yesterday555yesterday Clicks: 61 This Month: this11360this Clicks: 812 Last Month: last5350last Clicks: 454
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: Search for abcNUMBERdef, make it a variable, then do math?
by Jesse Smith (Acolyte) on Jan 22, 2011 at 09:10 UTC | |
by Jesse Smith (Acolyte) on Jan 22, 2011 at 09:26 UTC | |
by Anonyrnous Monk (Hermit) on Jan 22, 2011 at 13:28 UTC |