home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #30 / NN_1992_30.iso / spool / comp / lang / perl / 7447 < prev    next >
Encoding:
Internet Message Format  |  1992-12-15  |  872 b 

  1. 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
  2. From: utashiro@sran230.sra.co.jp (Kazumasa Utashiro)
  3. Newsgroups: comp.lang.perl
  4. Subject: Re: Perl-side globbing (was Re: Perl Shell...)
  5. Message-ID: <BzBvo6.96G@sran230.sra.co.jp>
  6. Date: 16 Dec 92 01:19:17 GMT
  7. References: <18086@autodesk.COM> <1992Dec10.073900.16503@spillman.uucp>
  8. Organization: Software Research Associates, Inc., Japan
  9. Lines: 12
  10.  
  11. For your interest, here is my shell wildcard to regexp
  12. subroutine.  This version works only for a filename (not a
  13. path).  I wonder you call this simple or complex :-)
  14.  
  15. sub wildcard {
  16.     local($_) = @_;
  17.     s#\\?.#$_ = $&; s/\\?([_0-9A-Za-z])/$1/ || /\\./ || s/[*]/.*/ ||
  18.     s/[|]/\$|^/ || tr/?{,}[]\-/.(|)[]\-/ || s/./\\$&/; $_;#ge;
  19.     length($_) ? "^$_\$" : undef;
  20. }
  21.  
  22. --utashiro
  23.