my @output_lines_array = `/path/to/your_executable`; foreach my $line (@output_lines_array) { if (/^No. of sequences \(letters\): ([\d,])\s/) { print "No. of sequences = $1\n"; } }