This is much more simple and isn't as sloppy.
#!/usr/bin/perl use strict; use warnings; print "Please enter text for string search: "; my $search=<STDIN>; chomp $search; print "Please specify directory: "; my $directory=<STDIN>; chomp $directory; opendir(DIR, $directory) or die "Cannot open dir ($!)\n"; my @files = grep(/\.JPEG|\.JPG/i, readdir(DIR)); @files = grep(/$search/, @files); closedir(DIR); my $file; foreach $file(@files){ print "$file\n"; }
In reply to Re: Search for text from user input
by Anonymous Monk
in thread Search for text from user input
by Nathan_84
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |