Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: string functions

by holli (Abbot)
on Oct 25, 2006 at 09:32 UTC ( [id://580521]=note: print w/replies, xml ) Need Help??


in reply to string functions

The following uses regexes and eval:
use strict; use warnings; my @p = (1.5, 2.5, 3.5 ); my @m = (0.5, 0.55, 0.60); my $a="2A2B2C"; sub calc { my $i = shift; my $j = ord(shift)-65; my $r = $p[$j]; $r *= $p[$j] for (0..$i-2); return $r * $m[$j]; } $a=~ s/([0-9]+)([A-Z])/(calc($1,"$2"))/g; $a=~ s/\)\(/)*(/g; eval "\$a = $a;"; print $a; #28.423828125


holli, /regexed monk/

Replies are listed 'Best First'.
A reply falls below the community's threshold of quality. You may see it by logging in.
A reply falls below the community's threshold of quality. You may see it by logging in.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others about the Monastery: (5)
As of 2024-03-29 13:38 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found