#!/usr/bin/env perl use warnings; use strict; open my $test_fh, '<', @ARGV or die "Can not open file $!\n"; while (<$test_fh>) { if (/\b[Ii]t\b(.*)[.,?]$/) { print "$1\n"; } } close $test_fh; #### if (/\b[Ii]t\b(.*[.,?])$/) {