$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.