princepawn has asked for the wisdom of the Perl Monks concerning the following question:
package Regexp; use strict; use vars qw($file_re); my $underscore = '_'; my $non_dot = '[^.]'; my $dot = '[.]'; $file_re = qr/((nonconsolidated|other)$underscore)?(faq|organization|literature +|contact|service)$underscore($non_dot+)${dot}xls/ ; 1; use Regexp; use strict; my @file = qw( Organization_DOT.xls.txt other_Service_FDNY.xls.txt nonconsolidated_FAQ_NYPD.xls.txt ); for (@file) { warn $_; if (/$Regexp::file_re/i) { warn "$1 $2 $3 $4"; warn $&; } else { warn 'AaaaaaaH'; } }
update (broquaint): added ending </ol> tag
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: [perlre] using qr - help needed
by gjb (Vicar) on Nov 07, 2002 at 21:55 UTC | |
|
Re: [perlre] using qr - help needed
by Aristotle (Chancellor) on Nov 08, 2002 at 01:43 UTC | |
|
Re: [perlre] using qr - help needed
by broquaint (Abbot) on Nov 08, 2002 at 00:03 UTC | |
|
Re: [perlre] using qr - help needed
by princepawn (Parson) on Nov 08, 2002 at 14:57 UTC | |
by broquaint (Abbot) on Nov 08, 2002 at 15:19 UTC | |
by Aristotle (Chancellor) on Nov 08, 2002 at 19:01 UTC |