I would like to read a file in perl, after, the user can input any string and grep will try to find the string inputted in the file read. It will only exit when the user input nothing or any space character. Here's my code which is not working:
#! usr/bin/perl
use warnings;
use strict;
open MATCHSTRING,"matchstring";
my @lines = <MATCHSTRING>;
while (<>) {
chomp;
my @match = grep {/\b$_\b/s} @lines;
print @match;
}
I'm still lacking the condition where it will exit once nothing is inputted or a newline or any space character.