use strict; my $line = "this is a test=234567 line"; if ($line =~ /.*test=(\d+)/){ print $1; } #### 234567