my $found = 0; #for each line while ($line = ) { #remove the carriage return chomp $line; #splits the line between tabs and get the different elements ($name, $city, $language) = split /\t/, $line; next unless $language =~ /$search/; $found++; print "$name can speak " . ($search) . " and lives in " . ($city) . ".\n"; } print "Found $found results.\n";