home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!olivea!charnel!rat!usc!sdd.hp.com!saimiri.primate.wisc.edu!ames!sun-barr!sh.wide!wnoc-tyo-news!sranha!sranhd!sran230!utashiro
- From: utashiro@sran230.sra.co.jp (Kazumasa Utashiro)
- Newsgroups: comp.lang.perl
- Subject: Re: Perl-side globbing (was Re: Perl Shell...)
- Message-ID: <BzBvo6.96G@sran230.sra.co.jp>
- Date: 16 Dec 92 01:19:17 GMT
- References: <18086@autodesk.COM> <1992Dec10.073900.16503@spillman.uucp>
- Organization: Software Research Associates, Inc., Japan
- Lines: 12
-
- For your interest, here is my shell wildcard to regexp
- subroutine. This version works only for a filename (not a
- path). I wonder you call this simple or complex :-)
-
- sub wildcard {
- local($_) = @_;
- s#\\?.#$_ = $&; s/\\?([_0-9A-Za-z])/$1/ || /\\./ || s/[*]/.*/ ||
- s/[|]/\$|^/ || tr/?{,}[]\-/.(|)[]\-/ || s/./\\$&/; $_;#ge;
- length($_) ? "^$_\$" : undef;
- }
-
- --utashiro
-