Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

Re: regex and string functions help needed.

by doowah2004 (Monk)
on Oct 25, 2006 at 13:58 UTC ( [id://580579]=note: print w/replies, xml ) Need Help??


in reply to regex and string functions help needed.

valavanp, I think this is what you wanted:
$a="ABC"; $b=length($a); print "$b\n"; for($i=0;$i<$b;$i++){ $a=~s/(\d+)(.)/$2 x $1/ge; } print "$a\n"; my %value = ( A => 2.74, B => 2.64, C => 2.5, ); my %factor = ( A => 50/100, B => 55/100, C => 60/100, ); my @letters = split //, $a; my $result = 1; my $temp=0; for my $letter (@letters) { $result *= $value{ $letter }; #print "$result\n"; }; my %seen; my @uniqed = grep !$seen{$_}++, @letters; for my $letter (@uniqed) { $result *= $factor{ $letter }; #print "$result\n"; }; print $result;
*UPDATE*
I did not refresh my browser before I posted, it appears the two post before this get the same results...

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://580579]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others avoiding work at the Monastery: (9)
As of 2024-04-23 17:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found