in reply to Working on pattern matching

Hello catfish1116,

Fellow Monks already told you the problem to your script. I would also to add a minor modification to possibly use a module IO::All so you do not need to bother with this minor issues and minimize your code on this part.

Sample of modification below:

#!/usr/bin/perl use strict; use warnings; use IO::All; use v5.16; ############## ## 03/14/19 ## Exercise reads from file, then lets user interactively submit matc +hing search criteria die "Please provide a file to process!\n" unless (defined $ARGV[0]); my @lines = io($ARGV[0])->chomp->slurp; # Chomp as you slurp while (1) { print 'Please enter a pattern: '; chomp(my $pattern = <STDIN>); last if $pattern =~ /\A\s*\Z/; my @matches = eval { grep /$pattern/, @lines; }; ## end of eval if ($@) { print "Error: $@"; } else { my $count = @matches; print "There were $count matching strings:\n", map "$_\n", @matches; } print "\n"; }

Hope this helps, BR.

Seeking for Perl wisdom...on the process of learning...not there...yet!