in reply to Re^2: Search for text from user input
in thread Search for text from user input

This is my attempt however is doesnt work and i get the error message:

Use of uninitialized value $_ in pattern match (m//) at search2.pl line 11, <STDIN> line 1.

Any ideas?

#!/usr/bin/perl -w -T print "Please enter text for string search? \n"; $search=<STDIN>; chop $search; opendir(DIR, "."); @files = grep (/\.jpg|\.jpeg|\.JPEG|\.JPG/, readdir(DIR)) and ($_ =~ m/\.'$search'/, readdir(DIR)); closedir(DIR); foreach $file (@files) { print "$file\n"; }