#!/usr/bin/perl use v5.35.0; my $sum = 0; while (<>) { s/mul\((\d{1,3}),(\d{1,3})\)/$sum += $1 * $2/ge; } say $sum;