in reply to Help with pattern matching and calling wc -l

For the wc command, wc -l returns the number of lines in the file, but also the file name. A sneaky circimvention is:
qx/wc -l < $file/;
which means it reads the file from stdin. Downside is that it uses a shell process for the redirection, so it is slow if you have a large number of files. The alternative is to open the file yourself and count the lines. Alternatively split off the filename from the wc output before using it as a numeric.