Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^2: Search for abcNUMBERdef, make it a variable, then do math?

by AnomalousMonk (Archbishop)
on Jan 22, 2011 at 09:16 UTC ( [id://883671]=note: print w/replies, xml ) Need Help??


in reply to Re: Search for abcNUMBERdef, make it a variable, then do math?
in thread Search for abcNUMBERdef, make it a variable, then do math?

$id4 =~ /yesterday(\d+)yesterday/; my $ans2 = $2 * .40; $final2 = ($ans2 / 100);

Jesse Smith: Further to CountZero's reply: in the above quoted and in subsequent steps in the OPed code, the capture variable  $2 (and subsequently  $3 $4) is used in a calculation, but there is no second (or third or fourth) capture group to populate this variable with a defined value. The fact it is undefined would have been made evident to you had you been using warnings (and strictures for good measure – and diagnostics for even better measure since you are learning Perl):

use warnings; use strict; use diagnostics;

See perlre, perlrequick, perlretut, perlreref for regular expression (re) on-line documentation, or  perldoc perlre etc for local installation documentation.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (4)
As of 2024-04-20 00:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found