Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Remove letters from variables used in math operation?

by BillKSmith (Deacon)
on Dec 09, 2012 at 03:22 UTC ( #1007947=note: print w/ replies, xml ) Need Help??


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

The use of several modules can increase the flexability of your code without introducing the potential errors mentioned by other responders.

use strict; use warnings; use v5.10.1; use Readonly; use List::Util qw(sum); use Regexp::Common; Readonly::Scalar my $NUMBER => qr/$RE{num}{real}/; while (my $line = <DATA>){ chop($line); say sum( $line=~/($NUMBER)/g ); } __DATA__ 86f,934e,92,102i,14,19,222,
Bill


Comment on Re: Remove letters from variables used in math operation?
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (8)
As of 2015-08-04 18:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The oldest computer book still on my shelves (or on my digital media) is ...













    Results (71 votes), past polls