Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Remove letters from variables used in math operation?

by AnomalousMonk (Canon)
on Dec 08, 2012 at 21:22 UTC ( #1007930=note: print w/replies, xml ) Need Help??


in reply to Remove letters from variables used in math operation?

Another peasibility:

>perl -wMstrict -le "my $s = '86f,934e,92,102i,14,19,222,'; ;; my ($a,$b,$c,$d,$e,$f,$g) = split m{ [[:alpha:]]* , }xms, $s; my $sum = ($a+$b+$c+$d+$e+$f+$g); ;; print $sum; " 1469

Update: Or even:

>perl -wMstrict -le "use List::Util qw(sum); ;; my $s = '86f,934e,92,102i,14,19,222,'; ;; my $sum = sum split m{ [[:alpha:]]* , }xms, $s; ;; print $sum; " 1469

Also (tested):  my $sum = sum $s =~ m{ \d+ }xmsg;

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1007930]
help
Chatterbox?
[choroba]: It has the widest rear seats space available in the same price category - needed for the 3 kids.
Discipulus families growth is related to price of cars nowadays..
[choroba]: price of anything, unfortunately
[Discipulus]: yes, unfortunately.
[Corion]: Discipulus: you can "easily" trap shutdown/logoff in a Win32::GUI application by capturing and responding to the appropriate message
[LanX]: choroba wants to scale further? :)
[Discipulus]: I read an article about how much the female condition has got worst in the eastern europe after the fall of social policies
LanX has a friend in Berlin who switched to go(lang) and just got a kid ...
[marto]: good morning all
[Corion]: Hi marto ;)

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (13)
As of 2017-01-17 09:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Do you watch meteor showers?




    Results (154 votes). Check out past polls.