use warnings; use strict; my $file_path = "/Users/anaordonez/Documents/my_languages.txt"; open(my $fh, '<', $file_path) or die "Sorry!! couldn't open '$file_path': $!"; print "Reading file \n"; while (my $line = <$fh>) { chomp $line; print "$line\n" if $line eq "Java"; } close($fh);