#/usr/bin/perl use strict; use warnings; use feature 'say'; my $lineWithMax; my $max = 0; my @numbers; my @lines = ; for my $line (@lines) { chomp($line); @numbers = $line =~ /(\d+)/g; foreach my $number (@numbers) { if ( $number > $max ) { $lineWithMax = $line; $max = $number; } } } say "Line with highest number is '$lineWithMax'"; __DATA__ Hello, i'm 18 1 this year is 2019 1 1 2 3 - 4