The problem is that each time you do this
-e <"$INTERIORNAME"*.pdf>
it returns a different filename and only a single filename. You need to assign that glob to an array and then grep for the pdf extension with a regex.
By the way according to the 3rd edition of Programming Perl from 2000 this is referred to as the old way to do it. They recommend something like this:
@files = glob("*.pdf");
In reply to Re: trouble with glob
by Gulliver
in thread trouble with glob
by kurt2439
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |