Path: utzoo!utgpu!jarvis.csri.toronto.edu!cs.utexas.edu!sun-barr!newstop!texsun!convex!tchrist From: tchrist@convex.com (Tom Christiansen) Newsgroups: comp.lang.perl Subject: <*glob*>: arguments too long Message-ID: <100207@convex.convex.com> Date: 23 Feb 90 14:43:36 GMT Sender: news@convex.com Reply-To: tchrist@convex.Com (Tom Christiansen) Organization: Convex Computer Corp, Richardson, TX Lines: 39 I've been running into this a bunch lately, which has taken me to writing a quick, drop-in replacement for <*.bar> type globbing. I think I'd really like Larry to look at internalizing file globbing. I think Piet van Oostrum has sent patches for this. Here's a routine that is a drop-in replacement for globbing that DOES NOT INVOLVE multi-level directories, although it does check for those. It's pretty quick. sub glob { local($expr) = @_; local(@retlist) = (); local(*METADIR); # paranoia die "glob: null expr" unless $expr; # assert if ($expr =~ /\//) { warn "glob: \"$expr\" has slashes, punting..."; return <${expr}>; } $expr =~ s/\*/.*/g; $expr =~ s/\?/./g; unless (opendir(METADIR, '.')) { warn "glob: can't opendir ".": $!"; } else { @retlist = sort grep(/$expr/o, grep(!/^\./, readdir(METADIR))); closedir METADIR; } return @retlist; } --tom -- Tom Christiansen {uunet,uiucdcs,sun}!convex!tchrist Convex Computer Corporation tchrist@convex.COM "EMACS belongs in : Editor too big!"