open (my $fh, '<', $file) or die "Oops: $!"; while (<$fh>) { print "$1\n" if /([[:print:]]+)/ } close $fh;