open (FILE, "< logfile") or die "Couldn't open for read logfile: $!"; while ($file_content = ) { if ( $file_content =~ m/Vc3/ ) { my @numbers = $file_content =~ /\[(\d+)\]/g; } } close (FILE);