in reply to How to make a module which exports a function, takes a list and returns a list?
package ParseFiles; #use strict; use vars qw(@ISA @EXPORT $VERSION); use Exporter; $VERSION = 0.01; @ISA = qw(Exporter); @EXPORT = qw(&wad_parsefiles); $VERSION = 0.01; sub wad_parsefiles (@); ################################################### # sub parsefiles - args (@file list) return (@expanded file list) # take a list of filename arguments and expand it to a full # list, with wildcards globbed and @filelists opened # and included sub wad_parsefiles { my ($filespec, @files, @readfile); foreach $filespec (@_) { # convert drive:\dir\file to drive:\\dir\\file to make perl happy $filespec =~ s/\\/\\\\/g; # check if arg begins w/ "@", treat as list if so if ( $filespec =~ /^@/ ) { # remove leading @ $filespec =~ s/^@//; # open the list and dump contents into @files if (open(FILELIST, "$filespec")){ @readfile = <FILELIST>; chomp(@readfile); close(FILELIST); @files = (@files, @readfile); } } # glob it? elsif ( $filespec =~ /\*/ || $filespec =~ /\?/ ) { @files = (@files, glob("$filespec")); } else { @files = (@files, "$filespec"); } } return @files; }
first: apologies for sloppy syntax, i'm trying to get this thing to work at all before i clean up the mess. variable declarations and their ilk have been changed many times just trying to get this to run, so it might look weird in it's current state.
second: what i'd like to do here is to have this function to see a list of file specs (as provided on the cmd line or wherever), to expand that list with globbing and what have you, and than present the list to whomever calls this function. i'd really like it to be totally private outside of the function itself so i don't kill myself in namespace land. any thoughts on what's here? any idea what the heck i'm doing wrong?
luma::s-video
|
|---|