in reply to Trying to read numbers from a text file

If you are only using integers, match on digits.

#!/usr/bin/env perl use strict; use warnings; my $line = "25 ((18 25 4) (3 12 1))\n"; my @words = $line =~ /(\d+)/g; my $M = $words[1] + $words[4]; print "$M\n";