Fun with Regexes

2003-03-15 Thread Pete Emerson
Is there an elegant way to make sure that a string contains a list of strings, but not necessarily in any particular order? Here's how I'm doing it: #!/usr/bin/perl -w use strict; my @strings=qw(onetwothree threeonetwo onetwonope); my @matches=qw(one two three); foreach my $string (@strings) {

Re: Fun with Regexes

2003-03-16 Thread david
"Pete Emerson" <[EMAIL PROTECTED]> wrote in message: > Is there an elegant way to make sure that a string contains a list of > strings, but not necessarily in any particular order? Here's how I'm doing > it: > > #!/usr/bin/perl -w > > use strict; > my @strings=qw(onetwothree threeonetwo onetwonope

Re: Fun with Regexes

2003-03-16 Thread Rob Dixon
Pete Emerson wrote: > Is there an elegant way to make sure that a string contains a list of > strings, but not necessarily in any particular order? Here's how I'm > doing > it: > > #!/usr/bin/perl -w > > use strict; > my @strings=qw(onetwothree threeonetwo onetwonope); > my @matches=qw(one two thre

Re: Fun with Regexes

2003-03-16 Thread Pete Emerson
Thanks for your code, I've gotta look up \Q to make sure I understand what's happening, but it looks great. I'm still parsing your comments to make sure I understand everything. I'm not quite sure what you meant about side effects from my conditional being frowned upon...how else do you use the ()

Re: Fun with Regexes

2003-03-16 Thread Rob Dixon
Pete Emerson wrote: > Thanks for your code, I've gotta look up \Q to make sure I understand > what's happening, but it looks great. I'm still parsing your comments > to make sure I understand everything. Within a string, \Q escapes (with '\') all following non-word characters (a-z, A-Z, 0-9 and un

Re: Fun with Regexes

2003-03-17 Thread Pete Emerson
Mar 16, 2003 at 5:08pm from Rob Dixon: RD> (print 'abc') + ($success = 0) + (last); Rob, thanks, this example helps drive the point home. Would you also argue that open INFILE, $file || die "Can't open $file: $!"; should really be written as die "Can't open $file: $!" if (!open INFIL

Re: Fun with Regexes

2003-03-17 Thread R. Joseph Newton
Pete Emerson wrote: > Mar 16, 2003 at 5:08pm from Rob Dixon: > > RD> (print 'abc') + ($success = 0) + (last); > > Rob, thanks, this example helps drive the point home. Would you also argue > that > > open INFILE, $file || die "Can't open $file: $!"; > > should really be written as > > die

Re: Fun with Regexes

2003-03-17 Thread Scott R. Godin
Pete Emerson wrote: > Mar 16, 2003 at 5:08pm from Rob Dixon: > > RD> (print 'abc') + ($success = 0) + (last); > > Rob, thanks, this example helps drive the point home. Would you also argue > that > > open INFILE, $file || die "Can't open $file: $!"; > > should really be written as > >

Re: Fun with Regexes

2003-03-17 Thread John W. Krahn
Pete Emerson wrote: > > Mar 16, 2003 at 5:08pm from Rob Dixon: > > RD> (print 'abc') + ($success = 0) + (last); > > Rob, thanks, this example helps drive the point home. Would you also argue > that > > open INFILE, $file || die "Can't open $file: $!"; > > should really be written as >