#!/usr/bin/perl use strict; use warnings; ############## ## 03/14/19 ## Exercise reads from file, then lets user interactively submit matching search criteria my $input_file = shift @ARGV; open my $fh, '<', $input_file or die "unable to open $input_file for searching $!"; chomp(my @strings = <$fh>); my $pattern; while ( (print 'Please enter a pattern: '),$pattern=, $pattern !~ /\A\s*\Z/) { chomp $pattern; my @matches = eval { grep /$pattern/, @strings; }; ## end of eval if ($@) { print "Error: $@"; } else { my $count = @matches; print "There were $count matching strings:\n", join ("\n",@matches); } print "\n"; }