Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion Groups
General
GeneralPortable MacsHardwareNetworking
Applications
Mac ApplicationsEudoraFirefox / MozillaInternet ExplorerOutlook ExpressMS OfficeEntourageExcelPowerPointWordVirtual PCMedia PlayerOther MS Products
Programming
Mac ProgrammingCodeWarriorPerl
Country Specific
Australian Mac GroupUK Mac Group

Mac Forum / Programming / Perl / May 2005



Tip: Looking for answers? Try searching our database.

performing a glob-style "wild card" match against a string?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Rich Morin - 22 May 2005 02:16 GMT
Using index(), I can find out if a string contains a specified substring.
Similarly, I can use a regular expression test to find out if a string
matches a particular pattern.  What I'm LOOKING FOR is a way to find out
if a string matches a particular "wild card" character sequence, as used
in glob(), etc.  For example:

  if (wcm($string, '/{foo,bar}.h') { ...

should match both

  $string = '/etc/bar.h';
  $string = '/usr/bar.h';

but not

  $string = '/etc/baz.h;

I suspect that I could munge the wild card expressions into REs, but I'm
hoping someone has already done this (or developed an alternative).

Help?

-r
Signature

email: rdm@cfcl.com; phone: +1 650-873-7841
http://www.cfcl.com        - Canta Forda Computer Laboratory
http://www.cfcl.com/Meta   - The FreeBSD Browser, Meta Project, etc.

Sherm Pendley - 22 May 2005 02:46 GMT
> What I'm LOOKING FOR is a way to find out
> if a string matches a particular "wild card" character sequence, as  
> used
> in glob(), etc.

Have a look at Text::Glob on CPAN.

sherm--

Cocoa programming in Perl: http://camelbones.sourceforge.net
Hire me! My resume: http://www.dot-app.org
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.