in reply to subroutine array empty

I am writing a quick subroutine to grab a list of files in a directory and return it as an array...

Just a side note: since the caller knows which directory is supposed to be scanned (and should also know that it's looking only for files whose names match "*.mp3" or something to that effect), there's no need for a subroutine call.

The code that would call your subroutine could just do this instead:

my @mp3files = <$path/*.mp3>;
(assuming that $path is what would have been passed when calling your subroutine). That use of angle brackets in perl is referred to as a "file glob".

Replies are listed 'Best First'.
Re^2: subroutine array empty
by davidov0009 (Scribe) on Dec 09, 2007 at 04:47 UTC
    Thank you so much for your quick replies. I knew it had to be something so simple I was messing up. I've been using CPAN modules so much writing my own subs has gotten rusty... That file glob is great and just what I needed, so simple. I'm going to strip off the directory name using some regexp's and then I'm good to go.
    use strict; use CGI;