From arocker at Vex.Net Mon Apr 1 07:17:29 2013 From: arocker at Vex.Net (arocker at Vex.Net) Date: Mon, 1 Apr 2013 10:17:29 -0400 Subject: [tpm] Future meeting topics Message-ID: <8887cf6ca91e08658ac499cce04a6aa7.squirrel@mail.vex.net> A couple of topics that look interesting: Test:: module use PDL (Perl Data Language) Is anybody else interested in or knowledgeable about either or both of these? From lists at alteeve.ca Fri Apr 12 22:29:02 2013 From: lists at alteeve.ca (Digimer) Date: Sat, 13 Apr 2013 01:29:02 -0400 Subject: [tpm] Breaking a string up into hash keys Message-ID: <5168ED1E.80508@alteeve.ca> Hi all, I've got a rather large, random-depth hash. ie: $conf->{foo}{bar} = "a"; $conf->{baz} = "1"; $conf->{this}{and}{the}{other}{thing} = "what?"; And so on. The number of hash keys can be quite varied, depending on the use. So now I want to be able to take a string that is in the format: foo::bar baz this::and::the::other::thing Split on the :: and use that to pull the value out of the hash. Any help would be much appreciated! :) -- Digimer Papers and Projects: https://alteeve.ca/w/ What if the cure for cancer is trapped in the mind of a person without access to education? From quantum.mechanic.1964 at gmail.com Sat Apr 13 07:18:27 2013 From: quantum.mechanic.1964 at gmail.com (Quantum Mechanic) Date: Sat, 13 Apr 2013 15:18:27 +0100 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: <5168ED1E.80508@alteeve.ca> References: <5168ED1E.80508@alteeve.ca> Message-ID: You could use s/// and an eval, if there's no security issue. Otherwise, treat it like a linked list, and walk the plank. Cheers, Shaun On Apr 13, 2013, at 6:29 AM, Digimer wrote: > Hi all, > > I've got a rather large, random-depth hash. ie: > > $conf->{foo}{bar} = "a"; > $conf->{baz} = "1"; > $conf->{this}{and}{the}{other}{thing} = "what?"; > > And so on. The number of hash keys can be quite varied, depending on the use. > > So now I want to be able to take a string that is in the format: > > foo::bar > baz > this::and::the::other::thing > > Split on the :: and use that to pull the value out of the hash. > > Any help would be much appreciated! :) > > -- > Digimer > Papers and Projects: https://alteeve.ca/w/ > What if the cure for cancer is trapped in the mind of a person without access to education? > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From antoniosun at lavabit.com Sat Apr 13 07:33:27 2013 From: antoniosun at lavabit.com (Antonio Sun) Date: Sat, 13 Apr 2013 10:33:27 -0400 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: <5168ED1E.80508@alteeve.ca> References: <5168ED1E.80508@alteeve.ca> Message-ID: On Sat, Apr 13, 2013 at 1:29 AM, Digimer wrote: > Hi all, > > I've got a rather large, random-depth hash. ie: > > $conf->{foo}{bar} = "a"; > $conf->{baz} = "1"; > $conf->{this}{and}{the}{other}**{thing} = "what?"; > > And so on. The number of hash keys can be quite varied, depending on the > use. > > So now I want to be able to take a string that is in the format: > > foo::bar > baz > this::and::the::other::thing > > Split on the :: and use that to pull the value out of the hash. > Use eval. It's pretty simple to transform "this::and::the::other::thing" into {this}{and}{the}{other}{thing}, and the next thing is to pull the value out of the hash: $ perl -d -e 0 DB<5> eval '$conf->{foo}{bar} = "a";' DB<6> p $conf->{foo}{bar} a HTH Antonio -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdice at pobox.com Sat Apr 13 08:11:43 2013 From: rdice at pobox.com (Richard Dice) Date: Sat, 13 Apr 2013 11:11:43 -0400 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: <5168ED1E.80508@alteeve.ca> References: <5168ED1E.80508@alteeve.ca> Message-ID: My solution is to go recursive... richard-dice-s-computer-9:Desktop rdice$ cat ./hashkeys.pl #!/usr/bin/env perl use warnings; use strict; use Data::Dumper qw ( Dumper ); my $conf; $conf->{foo}{bar} = "a"; $conf->{baz} = "1"; $conf->{this}{and}{the}{other}{thing} = "what?"; my @joinkeys = qw ( foo::bar baz this::and::the::other::thing ); foreach my $joinkey ( @joinkeys ) { my @bits = split /::/, $joinkey; print hashval($conf, \@bits); print "\n"; } exit 0; sub hashval { my ($hash, $keybits) = @_; if ( ref($hash->{$keybits->[0]}) eq 'HASH' ) { return hashval($hash->{$keybits->[0]}, [ @$keybits[1..$#$keybits]]); } elsif ( ! ref($hash->{$keybits->[0]}) ) { return $hash->{$keybits->[0]}; } else { die "Foo! They key string you gave me doesn't correspond to a known proper hash-of-hash entry within the 'conf' structure --> " . Dumper($hash, $keybits); } } richard-dice-s-computer-9:Desktop rdice$ ./hashkeys.pl a 1 what? On Sat, Apr 13, 2013 at 1:29 AM, Digimer wrote: > Hi all, > > I've got a rather large, random-depth hash. ie: > > $conf->{foo}{bar} = "a"; > $conf->{baz} = "1"; > $conf->{this}{and}{the}{other}**{thing} = "what?"; > > And so on. The number of hash keys can be quite varied, depending on the > use. > > So now I want to be able to take a string that is in the format: > > foo::bar > baz > this::and::the::other::thing > > Split on the :: and use that to pull the value out of the hash. > > Any help would be much appreciated! :) > > -- > Digimer > Papers and Projects: https://alteeve.ca/w/ > What if the cure for cancer is trapped in the mind of a person without > access to education? > ______________________________**_________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/**listinfo/toronto-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From quantum.mechanic.1964 at gmail.com Sat Apr 13 08:33:08 2013 From: quantum.mechanic.1964 at gmail.com (Quantum Mechanic) Date: Sat, 13 Apr 2013 16:33:08 +0100 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: References: <5168ED1E.80508@alteeve.ca> Message-ID: <8C745DA5-6EDD-4AB6-90A2-D6D9A7657D1F@gmail.com> Just hope the OP doesn't exceed the recursion limit ;) Now we just need someone to post a loop version, and we'll be done. Cheers, Shaun On Apr 13, 2013, at 4:11 PM, Richard Dice wrote: > My solution is to go recursive... > > richard-dice-s-computer-9:Desktop rdice$ cat ./hashkeys.pl > #!/usr/bin/env perl > > use warnings; > use strict; > > use Data::Dumper qw ( Dumper ); > > my $conf; > > $conf->{foo}{bar} = "a"; > $conf->{baz} = "1"; > $conf->{this}{and}{the}{other}{thing} = "what?"; > > my @joinkeys = qw ( > foo::bar > baz > this::and::the::other::thing > ); > > foreach my $joinkey ( @joinkeys ) { > my @bits = split /::/, $joinkey; > print hashval($conf, \@bits); > print "\n"; > } > > exit 0; > > sub hashval { > my ($hash, $keybits) = @_; > if ( ref($hash->{$keybits->[0]}) eq 'HASH' ) { > return hashval($hash->{$keybits->[0]}, [ @$keybits[1..$#$keybits]]); > } elsif ( ! ref($hash->{$keybits->[0]}) ) { > return $hash->{$keybits->[0]}; > } else { > die "Foo! They key string you gave me doesn't correspond to a known proper hash-of-hash entry within the 'conf' structure --> " . Dumper($hash, $keybits); > } > } > richard-dice-s-computer-9:Desktop rdice$ ./hashkeys.pl > a > 1 > what? > > > > On Sat, Apr 13, 2013 at 1:29 AM, Digimer wrote: > Hi all, > > I've got a rather large, random-depth hash. ie: > > $conf->{foo}{bar} = "a"; > $conf->{baz} = "1"; > $conf->{this}{and}{the}{other}{thing} = "what?"; > > And so on. The number of hash keys can be quite varied, depending on the use. > > So now I want to be able to take a string that is in the format: > > foo::bar > baz > this::and::the::other::thing > > Split on the :: and use that to pull the value out of the hash. > > Any help would be much appreciated! :) > > -- > Digimer > Papers and Projects: https://alteeve.ca/w/ > What if the cure for cancer is trapped in the mind of a person without access to education? > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From shlomif at shlomifish.org Sat Apr 13 20:08:17 2013 From: shlomif at shlomifish.org (Shlomi Fish) Date: Sun, 14 Apr 2013 06:08:17 +0300 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: References: <5168ED1E.80508@alteeve.ca> Message-ID: <20130414060817.77df0bd9@telaviv1.shlomifish.org> Hi Antonio, On Sat, 13 Apr 2013 10:33:27 -0400 Antonio Sun wrote: > On Sat, Apr 13, 2013 at 1:29 AM, Digimer wrote: > > > Hi all, > > > > I've got a rather large, random-depth hash. ie: > > > > $conf->{foo}{bar} = "a"; > > $conf->{baz} = "1"; > > $conf->{this}{and}{the}{other}**{thing} = "what?"; > > > > And so on. The number of hash keys can be quite varied, depending on the > > use. > > > > So now I want to be able to take a string that is in the format: > > > > foo::bar > > baz > > this::and::the::other::thing > > > > Split on the :: and use that to pull the value out of the hash. > > > > > Use eval. > > It's pretty simple to transform "this::and::the::other::thing" > into {this}{and}{the}{other}{thing}, and the next thing is to pull the > value out of the hash: > > > $ perl -d -e 0 > > DB<5> eval '$conf->{foo}{bar} = "a";' > > DB<6> p $conf->{foo}{bar} > a > Please avoid using string eval in that case, because it is potentially an extreme security risk. What if someone does: my $s = q{system("rm -fr ~");} eval $s; See: http://perl-begin.org/tutorials/bad-elements/#string-eval Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "Humanity" - Parody of Modern Life - http://shlom.in/humanity An apple a day keeps the doctor away. Two apples a day will keep two doctors away. ? one of Shlomi Fish?s relatives Please reply to list if it's a mailing list post - http://shlom.in/reply . From olaf.alders at gmail.com Sun Apr 14 05:53:35 2013 From: olaf.alders at gmail.com (Olaf Alders) Date: Sun, 14 Apr 2013 08:53:35 -0400 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: <20130414060817.77df0bd9@telaviv1.shlomifish.org> References: <5168ED1E.80508@alteeve.ca> <20130414060817.77df0bd9@telaviv1.shlomifish.org> Message-ID: <55168278-9A69-4FF4-B9CE-302EE35CC44B@gmail.com> > On Sat, 13 Apr 2013 10:33:27 -0400 > Antonio Sun wrote: > >> On Sat, Apr 13, 2013 at 1:29 AM, Digimer wrote: >> >>> Hi all, >>> >>> I've got a rather large, random-depth hash. ie: >>> >>> $conf->{foo}{bar} = "a"; >>> $conf->{baz} = "1"; >>> $conf->{this}{and}{the}{other}**{thing} = "what?"; >>> >>> And so on. The number of hash keys can be quite varied, depending on the >>> use. >>> >>> So now I want to be able to take a string that is in the format: >>> >>> foo::bar >>> baz >>> this::and::the::other::thing >>> >>> Split on the :: and use that to pull the value out of the hash. >>> You can just flatten the hash, switch the "::" with dots and look up the key that way. #!/usr/bin/env perl use strict; use warnings; use feature qw( say ); use Data::Printer; # exports "p" use Hash::Flatten qw( flatten ); my $conf; $conf->{foo}{bar} = "a"; $conf->{baz} = "1"; $conf->{this}{and}{the}{other}{thing} = "what?"; my $flat = flatten( $conf ); my $key = 'this::and::the::other::thing'; $key =~ s/::/./g; p $conf; p $flat; say $flat->{$key}; ####################################### olaf-alderss-macbook-pro.local[~/Documents/perl] $ perl flatten.pl \ { baz => 1, foo => { bar => "a", }, this => { and => { the => { other => { thing => "what?", }, }, }, }, } \ { baz => 1, foo.bar => "a", this.and.the.other.thing => "what?", } what? -- Olaf Alders olaf.alders at gmail.com http://www.wundercounter.com http://twitter.com/wundercounter 866 503 2204 (Toll free - North America) 416 944 8306 (direct) From uri at stemsystems.com Sun Apr 14 08:43:46 2013 From: uri at stemsystems.com (Uri Guttman) Date: Sun, 14 Apr 2013 11:43:46 -0400 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: <55168278-9A69-4FF4-B9CE-302EE35CC44B@gmail.com> References: <5168ED1E.80508@alteeve.ca> <20130414060817.77df0bd9@telaviv1.shlomifish.org> <55168278-9A69-4FF4-B9CE-302EE35CC44B@gmail.com> Message-ID: <516ACEB2.4080802@stemsystems.com> On 04/14/2013 08:53 AM, Olaf Alders wrote: > use Hash::Flatten qw( flatten ); you don't need that module if you just use a very obscure but valid perl trick call multidimensional hashes. this is from old perl4 days but still works. if you use a list as the key in a scalar hash lookup, the list is joined with $; (see perlvar) and used as a single key. $; defaults to "\034" which is not printable. note that that value is unlikely to be in any printable key so the joined string will be unique and work as a flat hash key. so all you need to do is use that trick to generate the single level hash and also to access it. > > my $key = 'this::and::the::other::thing'; > $key =~ s/::/./g; instead of s/// just do a split on :: my @keys = split /::/, $keys ; $flat{ @keys } = 'foo' ; if that doesn't work because the array is put into scalar context, you can do the join directly: $flat{ join $;, @keys } = 'foo' ; and stay away from string eval for any normal data manipulation. it is slow and dangerous and actually rarely needed. it is NOT needed here at all. uri From janes.rob at gmail.com Sun Apr 14 09:04:03 2013 From: janes.rob at gmail.com (Rob Janes) Date: Sun, 14 Apr 2013 12:04:03 -0400 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: <8C745DA5-6EDD-4AB6-90A2-D6D9A7657D1F@gmail.com> References: <5168ED1E.80508@alteeve.ca> <8C745DA5-6EDD-4AB6-90A2-D6D9A7657D1F@gmail.com> Message-ID: happy to oblige ... my %hash; $hash{a}{b}{c}{d}{e} = 5; my $value = \%hash; $value = $value->{$_} foreach split /::/, "a::b::c::d::e"; so, while (<>) { chomp; my $value = \%data; $value = $value->{$_} foreach split /::/; print "$_ is $value\n"; } i think that should work. On Sat, Apr 13, 2013 at 11:33 AM, Quantum Mechanic wrote: > Just hope the OP doesn't exceed the recursion limit ;) > > Now we just need someone to post a loop version, and we'll be done. > > Cheers, > Shaun > > On Apr 13, 2013, at 4:11 PM, Richard Dice wrote: > > My solution is to go recursive... > > richard-dice-s-computer-9:Desktop rdice$ cat ./hashkeys.pl > #!/usr/bin/env perl > > use warnings; > use strict; > > use Data::Dumper qw ( Dumper ); > > my $conf; > > $conf->{foo}{bar} = "a"; > $conf->{baz} = "1"; > $conf->{this}{and}{the}{other}{thing} = "what?"; > > my @joinkeys = qw ( > foo::bar > baz > this::and::the::other::thing > ); > > foreach my $joinkey ( @joinkeys ) { > my @bits = split /::/, $joinkey; > print hashval($conf, \@bits); > print "\n"; > } > > exit 0; > > sub hashval { > my ($hash, $keybits) = @_; > if ( ref($hash->{$keybits->[0]}) eq 'HASH' ) { > return hashval($hash->{$keybits->[0]}, [ @$keybits[1..$#$keybits]]); > } elsif ( ! ref($hash->{$keybits->[0]}) ) { > return $hash->{$keybits->[0]}; > } else { > die "Foo! They key string you gave me doesn't correspond to a known > proper hash-of-hash entry within the 'conf' structure --> " . Dumper($hash, > $keybits); > } > } > richard-dice-s-computer-9:Desktop rdice$ ./hashkeys.pl > a > 1 > what? > > > > On Sat, Apr 13, 2013 at 1:29 AM, Digimer wrote: >> >> Hi all, >> >> I've got a rather large, random-depth hash. ie: >> >> $conf->{foo}{bar} = "a"; >> $conf->{baz} = "1"; >> $conf->{this}{and}{the}{other}{thing} = "what?"; >> >> And so on. The number of hash keys can be quite varied, depending on the >> use. >> >> So now I want to be able to take a string that is in the format: >> >> foo::bar >> baz >> this::and::the::other::thing >> >> Split on the :: and use that to pull the value out of the hash. >> >> Any help would be much appreciated! :) >> >> -- >> Digimer >> Papers and Projects: https://alteeve.ca/w/ >> What if the cure for cancer is trapped in the mind of a person without >> access to education? >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > From janes.rob at gmail.com Sun Apr 14 09:44:48 2013 From: janes.rob at gmail.com (Rob Janes) Date: Sun, 14 Apr 2013 12:44:48 -0400 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: <516ACEB2.4080802@stemsystems.com> References: <5168ED1E.80508@alteeve.ca> <20130414060817.77df0bd9@telaviv1.shlomifish.org> <55168278-9A69-4FF4-B9CE-302EE35CC44B@gmail.com> <516ACEB2.4080802@stemsystems.com> Message-ID: It's not a deep hash though. it's just composing a single key by joining with an obscure character that you're unlikely to find in a key normally. Sure, it should work fine, and will probably be a lot speedier than lookups by loop or recursion. On the other hand, if there's a lot in the hash, this method could result in a lot of hash collisions and inefficient lookups. And, on the other other hand, to see that slow things down so much that this multidimensional thing will be slower than loop/recursion ...that would be a corner case. On Sun, Apr 14, 2013 at 11:43 AM, Uri Guttman wrote: > On 04/14/2013 08:53 AM, Olaf Alders wrote: > >> use Hash::Flatten qw( flatten ); > > > you don't need that module if you just use a very obscure but valid perl > trick call multidimensional hashes. this is from old perl4 days but still > works. if you use a list as the key in a scalar hash lookup, the list is > joined with $; (see perlvar) and used as a single key. $; defaults to "\034" > which is not printable. note that that value is unlikely to be in any > printable key so the joined string will be unique and work as a flat hash > key. > > so all you need to do is use that trick to generate the single level hash > and also to access it. > >> >> my $key = 'this::and::the::other::thing'; >> $key =~ s/::/./g; > > > instead of s/// just do a split on :: > > my @keys = split /::/, $keys ; > > $flat{ @keys } = 'foo' ; > > if that doesn't work because the array is put into scalar context, you can > do the join directly: > > $flat{ join $;, @keys } = 'foo' ; > > and stay away from string eval for any normal data manipulation. it is slow > and dangerous and actually rarely needed. it is NOT needed here at all. > > uri > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From uri at stemsystems.com Sun Apr 14 09:59:46 2013 From: uri at stemsystems.com (Uri Guttman) Date: Sun, 14 Apr 2013 12:59:46 -0400 Subject: [tpm] Breaking a string up into hash keys In-Reply-To: References: <5168ED1E.80508@alteeve.ca> <20130414060817.77df0bd9@telaviv1.shlomifish.org> <55168278-9A69-4FF4-B9CE-302EE35CC44B@gmail.com> <516ACEB2.4080802@stemsystems.com> Message-ID: <516AE082.5040502@stemsystems.com> On 04/14/2013 12:44 PM, Rob Janes wrote: > It's not a deep hash though. it's just composing a single key by > joining with an obscure character that you're unlikely to find in a > key normally. i didn't say it was a deep hash. it is just a different way to get multilevel hashes with simpler and faster code. > > Sure, it should work fine, and will probably be a lot speedier than > lookups by loop or recursion. On the other hand, if there's a lot in > the hash, this method could result in a lot of hash collisions and > inefficient lookups. And, on the other other hand, to see that slow > things down so much that this multidimensional thing will be slower > than loop/recursion ...that would be a corner case. one hash lookup will always beat a loop descending into a hash. and normally i would never recommend this trick due to the requirement of not allowing $; to be in the key. but given how almost all hash keys are usually printable, this isn't a problem in most cases. i doubt there would be any more collisions than with any hash design. a flat hash will grow its bucket array as needed just like any other perl hash which does that to lower collisions. uri From lists at alteeve.ca Sun Apr 14 12:30:12 2013 From: lists at alteeve.ca (Digimer) Date: Sun, 14 Apr 2013 15:30:12 -0400 Subject: [tpm] Solved! Re: Breaking a string up into hash keys In-Reply-To: <5168ED1E.80508@alteeve.ca> References: <5168ED1E.80508@alteeve.ca> Message-ID: <516B03C4.3000809@alteeve.ca> On 04/13/2013 01:29 AM, Digimer wrote: > Hi all, > > I've got a rather large, random-depth hash. ie: > > $conf->{foo}{bar} = "a"; > $conf->{baz} = "1"; > $conf->{this}{and}{the}{other}{thing} = "what?"; > > And so on. The number of hash keys can be quite varied, depending on > the use. > > So now I want to be able to take a string that is in the format: > > foo::bar > baz > this::and::the::other::thing > > Split on the :: and use that to pull the value out of the hash. > > Any help would be much appreciated! :) > Thanks to everyone who responded! I've been only playing with perl for the last year or two, so some of the replies went over my head, I must admit. However, I was able to come up with a work-able solution; ==== use strict; use warnings; my $conf = {}; $conf->{string}{lang}{en_CA}{lang}{long_name} = "Canadian English"; my $key = "string::lang::en_CA::lang::long_name"; my ($value) = _get_hash_value($conf, $key); print "Key: [$key], value: [$value]\n"; sub _get_hash_value { my ($conf, $key_string) = @_; my @keys = split /::/, $key_string; my $last_key = pop @keys; my $this_href = $conf; while (my $key = shift @keys) { $this_href = $this_href->{$key}; } my $value = $this_href->{$last_key}; return($value); } ==== $ ./prog Key: [string::lang::en_CA::lang::long_name], value: [Canadian English] Again, thanks to all who responded! -- Digimer Papers and Projects: https://alteeve.ca/w/ What if the cure for cancer is trapped in the mind of a person without access to education? From lists at alteeve.ca Sun Apr 14 12:31:53 2013 From: lists at alteeve.ca (Digimer) Date: Sun, 14 Apr 2013 15:31:53 -0400 Subject: [tpm] Solved! Re: Breaking a string up into hash keys In-Reply-To: <516B03C4.3000809@alteeve.ca> References: <5168ED1E.80508@alteeve.ca> <516B03C4.3000809@alteeve.ca> Message-ID: <516B0429.5090606@alteeve.ca> > Thanks to everyone who responded! I've been only playing with perl for > the last year or two, so some of the replies went over my head, I must > admit. However, I was able to come up with a work-able solution; Woops, I meant "I have not been playing with perl much in the last year or two"*. At least, not in any professional or challenging way. :) -- Digimer Papers and Projects: https://alteeve.ca/w/ What if the cure for cancer is trapped in the mind of a person without access to education? From legrady at gmail.com Thu Apr 18 16:52:27 2013 From: legrady at gmail.com (Tom Legrady) Date: Thu, 18 Apr 2013 19:52:27 -0400 Subject: [tpm] License Plate Message-ID: Driving b ack from Kitchener, today, I found myself behind a car with license plate LARYWOL .... Would have loved to stop and talked to the guy Tom -------------- next part -------------- An HTML attachment was scrubbed... URL: From fulko.hew at gmail.com Fri Apr 19 07:58:33 2013 From: fulko.hew at gmail.com (Fulko Hew) Date: Fri, 19 Apr 2013 10:58:33 -0400 Subject: [tpm] how to resubstitute a captured value Message-ID: The subject line may not say it properly, but I need a _single_ (because of other constraints) s/// statement that effectively performs the following: If the string doesn't start with a hyphen and end with colon, then I want them added. ie: stuff => -stuff: -stuff => -stuff: stuff: => -stuff: -stuff: => -stuff: -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Fri Apr 19 08:07:16 2013 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Fri, 19 Apr 2013 11:07:16 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: Message-ID: Not the most efficient, but you can just always remove and add them back: #!/usr/bin/perl use strict; while (my $line = ) { $line =~ s/^-?(.+?):?$/-$1:/; print $line; } __DATA__ stuff -stuff stuff: -stuff: -- dave.s.doyle at gmail.com On 19 April 2013 10:58, Fulko Hew wrote: > The subject line may not say it properly, but I need > a _single_ (because of other constraints) s/// statement > that effectively performs the following: > > If the string doesn't start with a hyphen and end with colon, > then I want them added. > > ie: > > stuff => -stuff: > -stuff => -stuff: > stuff: => -stuff: > -stuff: => -stuff: > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fulko.hew at gmail.com Fri Apr 19 08:16:37 2013 From: fulko.hew at gmail.com (Fulko Hew) Date: Fri, 19 Apr 2013 11:16:37 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: Message-ID: Thats what I started with, but... I forgot to mention that the match expression and replacement expresssion need to be inside variables ie. #!/usr/bin/perl use strict; my $match = '^-?(.+?):?$'; my $replace = '-$1:'; while (my $line = ) { $line =~ s/$match/$replace/; print $line; } __DATA__ stuff -stuff stuff: -stuff: On Fri, Apr 19, 2013 at 11:07 AM, Dave Doyle wrote: > Not the most efficient, but you can just always remove and add them back: > > #!/usr/bin/perl > > use strict; > > while (my $line = ) { > $line =~ s/^-?(.+?):?$/-$1:/; > print $line; > } > > __DATA__ > stuff > -stuff > stuff: > -stuff: > > > -- > dave.s.doyle at gmail.com > > > On 19 April 2013 10:58, Fulko Hew wrote: > >> The subject line may not say it properly, but I need >> a _single_ (because of other constraints) s/// statement >> that effectively performs the following: >> >> If the string doesn't start with a hyphen and end with colon, >> then I want them added. >> >> ie: >> >> stuff => -stuff: >> -stuff => -stuff: >> stuff: => -stuff: >> -stuff: => -stuff: >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Fri Apr 19 08:27:27 2013 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Fri, 19 Apr 2013 11:27:27 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: Message-ID: So long as start and end don't have to be regexes themselves: #!/usr/bin/perl use strict; my ($start,$end) = ('-',':'); while (my $line = ) { $line =~ s/^(?:\Q$start\E)?(.+?)(?:\Q$end\E)?$/$start$1$end/; print $line; } __DATA__ stuff -stuff stuff: -stuff: -- dave.s.doyle at gmail.com On 19 April 2013 11:16, Fulko Hew wrote: > Thats what I started with, but... > I forgot to mention that the match expression and replacement > expresssion need to be inside variables > ie. > > #!/usr/bin/perl > use strict; > my $match = '^-?(.+?):?$'; > my $replace = '-$1:'; > > > while (my $line = ) { > $line =~ s/$match/$replace/; > > print $line; > } > __DATA__ > stuff > -stuff > stuff: > -stuff: > > > On Fri, Apr 19, 2013 at 11:07 AM, Dave Doyle wrote: > >> Not the most efficient, but you can just always remove and add them back: >> >> #!/usr/bin/perl >> >> use strict; >> >> while (my $line = ) { >> $line =~ s/^-?(.+?):?$/-$1:/; >> print $line; >> } >> >> __DATA__ >> stuff >> -stuff >> stuff: >> -stuff: >> >> >> -- >> dave.s.doyle at gmail.com >> >> >> On 19 April 2013 10:58, Fulko Hew wrote: >> >>> The subject line may not say it properly, but I need >>> a _single_ (because of other constraints) s/// statement >>> that effectively performs the following: >>> >>> If the string doesn't start with a hyphen and end with colon, >>> then I want them added. >>> >>> ie: >>> >>> stuff => -stuff: >>> -stuff => -stuff: >>> stuff: => -stuff: >>> -stuff: => -stuff: >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >>> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From fulko.hew at gmail.com Fri Apr 19 08:40:19 2013 From: fulko.hew at gmail.com (Fulko Hew) Date: Fri, 19 Apr 2013 11:40:19 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: Message-ID: On Fri, Apr 19, 2013 at 11:27 AM, Dave Doyle wrote: > > So long as start and end don't have to be regexes themselves: ... snip ... Its not that start and end are regexes, its that the match and replace need to be regexes The two pattens must be wholly contained within variables (because they are coming from a config file/table) so that means the right hand side needs to be interpolated? Therefore the constraint is: #!/usr/bin/perl use strict; while (my $line = ) { my $match = '^-?(.+?):?$'; my $replace = '-$1:'; $line =~ s/$match/$replace/; <= something magic happens here given $match and $replace print $line; } __DATA__ stuff -stuff stuff: -stuff: From mike at stok.ca Fri Apr 19 08:58:38 2013 From: mike at stok.ca (Mike Stok) Date: Fri, 19 Apr 2013 11:58:38 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: Message-ID: <5B08E58F-6506-44EF-8049-843AEC41BB94@stok.ca> If I was feeling crazy #!/usr/bin/perl use strict; my $match = '^-?(.+?):?$'; my $replace = '"-$1:"'; # note the quotes... while (my $line = ) { $line =~ s/$match/$replace/ee; print $line; } __DATA__ stuff -stuff stuff: -stuff: On 2013-04-19, at 11:16 AM, Fulko Hew wrote: > #!/usr/bin/perl > use strict; > my $match = '^-?(.+?):?$'; > my $replace = '-$1:'; > > while (my $line = ) { > $line =~ s/$match/$replace/; > print $line; > } > __DATA__ > stuff > -stuff > stuff: > -stuff: -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Fri Apr 19 08:59:34 2013 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Fri, 19 Apr 2013 11:59:34 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: <5B08E58F-6506-44EF-8049-843AEC41BB94@stok.ca> References: <5B08E58F-6506-44EF-8049-843AEC41BB94@stok.ca> Message-ID: Hah. Was just about to do the same. -- dave.s.doyle at gmail.com On 19 April 2013 11:58, Mike Stok wrote: > If I was feeling crazy > > #!/usr/bin/perl > use strict; > my $match = '^-?(.+?):?$'; > my $replace = '"-$1:"'; # note the quotes... > > while (my $line = ) { > $line =~ s/$match/$replace/ee; > print $line; > } > __DATA__ > stuff > -stuff > stuff: > -stuff: > > > On 2013-04-19, at 11:16 AM, Fulko Hew wrote: > > #!/usr/bin/perl > use strict; > my $match = '^-?(.+?):?$'; > my $replace = '-$1:'; > > while (my $line = ) { > $line =~ s/$match/$replace/; > print $line; > } > __DATA__ > stuff > -stuff > stuff: > -stuff: > > > -- > > Mike Stok > http://www.stok.ca/~mike/ > > The "`Stok' disclaimers" apply. > > > > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From dave.s.doyle at gmail.com Fri Apr 19 09:02:26 2013 From: dave.s.doyle at gmail.com (Dave Doyle) Date: Fri, 19 Apr 2013 12:02:26 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: <5B08E58F-6506-44EF-8049-843AEC41BB94@stok.ca> Message-ID: didn't know about the s///ee trick though. I had done this: #!/usr/bin/perl use strict; my $match = '^-?(.+?):?$'; my $replace = '"-$1:"'; while (my $line = ) { $line =~ s/$match/eval $replace/e; print $line; } __DATA__ stuff -stuff stuff: -stuff: -- dave.s.doyle at gmail.com On 19 April 2013 11:59, Dave Doyle wrote: > Hah. Was just about to do the same. > > -- > dave.s.doyle at gmail.com > > > On 19 April 2013 11:58, Mike Stok wrote: > >> If I was feeling crazy >> >> #!/usr/bin/perl >> use strict; >> my $match = '^-?(.+?):?$'; >> my $replace = '"-$1:"'; # note the quotes... >> >> while (my $line = ) { >> $line =~ s/$match/$replace/ee; >> print $line; >> } >> __DATA__ >> stuff >> -stuff >> stuff: >> -stuff: >> >> >> On 2013-04-19, at 11:16 AM, Fulko Hew wrote: >> >> #!/usr/bin/perl >> use strict; >> my $match = '^-?(.+?):?$'; >> my $replace = '-$1:'; >> >> while (my $line = ) { >> $line =~ s/$match/$replace/; >> print $line; >> } >> __DATA__ >> stuff >> -stuff >> stuff: >> -stuff: >> >> >> -- >> >> Mike Stok >> http://www.stok.ca/~mike/ >> >> The "`Stok' disclaimers" apply. >> >> >> >> >> > -------------- next part -------------- An HTML attachment was scrubbed... URL: From rdice at pobox.com Fri Apr 19 09:08:19 2013 From: rdice at pobox.com (Richard Dice) Date: Fri, 19 Apr 2013 12:08:19 -0400 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: <5B08E58F-6506-44EF-8049-843AEC41BB94@stok.ca> Message-ID: It's not just s///ee. It's as many e's as you want / need, though of course with more e's that way lies madness... I remember people talking about Lenzo using 5 e's in a s///eeeee when I was at YAPC 19100, though some people when they told they story said it was only 4. Ahh, apocrypha... :-) Cheers, - Richard On Fri, Apr 19, 2013 at 12:02 PM, Dave Doyle wrote: > didn't know about the s///ee trick though. I had done this: > > #!/usr/bin/perl > > use strict; > > my $match = '^-?(.+?):?$'; > my $replace = '"-$1:"'; > > > while (my $line = ) { > $line =~ s/$match/eval $replace/e; > print $line; > } > > __DATA__ > stuff > -stuff > stuff: > -stuff: > > > -- > dave.s.doyle at gmail.com > > > On 19 April 2013 11:59, Dave Doyle wrote: > >> Hah. Was just about to do the same. >> >> -- >> dave.s.doyle at gmail.com >> >> >> On 19 April 2013 11:58, Mike Stok wrote: >> >>> If I was feeling crazy >>> >>> #!/usr/bin/perl >>> use strict; >>> my $match = '^-?(.+?):?$'; >>> my $replace = '"-$1:"'; # note the quotes... >>> >>> while (my $line = ) { >>> $line =~ s/$match/$replace/ee; >>> print $line; >>> } >>> __DATA__ >>> stuff >>> -stuff >>> stuff: >>> -stuff: >>> >>> >>> On 2013-04-19, at 11:16 AM, Fulko Hew wrote: >>> >>> #!/usr/bin/perl >>> use strict; >>> my $match = '^-?(.+?):?$'; >>> my $replace = '-$1:'; >>> >>> while (my $line = ) { >>> $line =~ s/$match/$replace/; >>> print $line; >>> } >>> __DATA__ >>> stuff >>> -stuff >>> stuff: >>> -stuff: >>> >>> >>> -- >>> >>> Mike Stok >>> http://www.stok.ca/~mike/ >>> >>> The "`Stok' disclaimers" apply. >>> >>> >>> >>> >>> >> > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From shlomif at shlomifish.org Fri Apr 19 23:00:14 2013 From: shlomif at shlomifish.org (Shlomi Fish) Date: Sat, 20 Apr 2013 09:00:14 +0300 Subject: [tpm] how to resubstitute a captured value In-Reply-To: References: <5B08E58F-6506-44EF-8049-843AEC41BB94@stok.ca> Message-ID: <20130420090014.7d799c3e@telaviv1.shlomifish.org> Hi Dave, all, On Fri, 19 Apr 2013 12:02:26 -0400 Dave Doyle wrote: > didn't know about the s///ee trick though. I had done this: > It's not a good idea to use more than one /e in production code: http://perl-begin.org/tutorials/bad-elements/#string-eval > #!/usr/bin/perl > > use strict; > All of you did not add "use warnings;" as well. You should have. Regards, Shlomi Fish > my $match = '^-?(.+?):?$'; > my $replace = '"-$1:"'; > > > while (my $line = ) { > $line =~ s/$match/eval $replace/e; > print $line; > } > > __DATA__ > stuff > -stuff > stuff: > -stuff: > > > -- > dave.s.doyle at gmail.com > > > On 19 April 2013 11:59, Dave Doyle wrote: > > > Hah. Was just about to do the same. > > > > -- > > dave.s.doyle at gmail.com > > > > > > On 19 April 2013 11:58, Mike Stok wrote: > > > >> If I was feeling crazy > >> > >> #!/usr/bin/perl > >> use strict; > >> my $match = '^-?(.+?):?$'; > >> my $replace = '"-$1:"'; # note the quotes... > >> > >> while (my $line = ) { > >> $line =~ s/$match/$replace/ee; > >> print $line; > >> } > >> __DATA__ > >> stuff > >> -stuff > >> stuff: > >> -stuff: > >> > >> > >> On 2013-04-19, at 11:16 AM, Fulko Hew wrote: > >> > >> #!/usr/bin/perl > >> use strict; > >> my $match = '^-?(.+?):?$'; > >> my $replace = '-$1:'; > >> > >> while (my $line = ) { > >> $line =~ s/$match/$replace/; > >> print $line; > >> } > >> __DATA__ > >> stuff > >> -stuff > >> stuff: > >> -stuff: > >> > >> > >> -- > >> > >> Mike Stok > >> http://www.stok.ca/~mike/ > >> > >> The "`Stok' disclaimers" apply. > >> > >> > >> > >> > >> > > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Escape from GNU Autohell - http://www.shlomifish.org/open-source/anti/autohell/ Chuck Norris reads all messages posted to LKML (= the Linux Kernel Mailing List), understands them all, and he kills all gnomes he sees in sight. ? http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/ Please reply to list if it's a mailing list post - http://shlom.in/reply . From cj at enersave.ca Mon Apr 22 11:13:59 2013 From: cj at enersave.ca (Chris Jones) Date: Mon, 22 Apr 2013 14:13:59 -0400 Subject: [tpm] Help with Apache configuration In-Reply-To: References: Message-ID: <20130422181408.70B2111DFDE@xx1.develooper.com> I am wondering if someone might be willing to help me straighten out my httpd.conf file to get a website on my local computer working. I have succeeded in getting the first page, the index.html page up but the subsequent cgi scripts return an error. Or can you point me to the approproate apache mailing list. Thank you! >> Christopher Jones, P.Eng. Suite 1801, 1 Yonge Street Toronto, ON M5E1W7 Tel. 416-203-7465 Fax. 416-946-1005 email cj at enersave.ca -------------- next part -------------- An HTML attachment was scrubbed... URL: From lists at alteeve.ca Mon Apr 22 11:25:27 2013 From: lists at alteeve.ca (Digimer) Date: Mon, 22 Apr 2013 14:25:27 -0400 Subject: [tpm] Help with Apache configuration In-Reply-To: <20130422181408.70B2111DFDE@xx1.develooper.com> References: <20130422181408.70B2111DFDE@xx1.develooper.com> Message-ID: <51758097.2050906@alteeve.ca> On 04/22/2013 02:13 PM, Chris Jones wrote: > I am wondering if someone might be willing to help me straighten out my > httpd.conf file to get a website on my local computer working. I have > succeeded in getting the first page, the index.html page up but the > subsequent cgi scripts return an error. Or can you point me to the > approproate apache mailing list. > > Thank you! I've got some internal~ish notes on how I set up apache here; https://alteeve.ca/w/PPPower_Server#Apache It's not really written for general consumption, but I do use it for plenty of perl stuff and it works well. digimer -- Digimer Papers and Projects: https://alteeve.ca/w/ What if the cure for cancer is trapped in the mind of a person without access to education? From indy at indigostar.com Mon Apr 22 11:32:06 2013 From: indy at indigostar.com (Indy Singh) Date: Mon, 22 Apr 2013 14:32:06 -0400 Subject: [tpm] Help with Apache configuration In-Reply-To: <20130422181408.70B2111DFDE@xx1.develooper.com> References: <20130422181408.70B2111DFDE@xx1.develooper.com> Message-ID: Hi, Are you using Windows or Linux? If Windows, and if you want to start with a working configuration and compare it with your non-working configuration you can install IndigoAMPP from here: http://www.indigostar.com/indigoampp.php This installation contains Apache, Perl, PHP and MySQL. It?s a little out of date, but should be fine for your needs. Also note that on Windows your Perl scripts must start with a line that points to the Perl installation, e.g: #!C:\perl\bin\perl or just: #!perl Indy Singh IndigoSTAR Software -- www.indigostar.com From: Chris Jones Sent: Monday, April 22, 2013 2:13 PM To: TPM Subject: [tpm] Help with Apache configuration I am wondering if someone might be willing to help me straighten out my httpd.conf file to get a website on my local computer working. I have succeeded in getting the first page, the index.html page up but the subsequent cgi scripts return an error. Or can you point me to the approproate apache mailing list. Thank you! >> Christopher Jones, P.Eng. Suite 1801, 1 Yonge Street Toronto, ON M5E1W7 Tel. 416-203-7465 Fax. 416-946-1005 email cj at enersave.ca -------------------------------------------------------------------------------- _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From cj at enersave.ca Mon Apr 22 12:59:12 2013 From: cj at enersave.ca (Chris Jones) Date: Mon, 22 Apr 2013 15:59:12 -0400 Subject: [tpm] Help with Apache configuration In-Reply-To: References: <20130422181408.70B2111DFDE@xx1.develooper.com> Message-ID: <20130422195911.07DBE11DB69@xx1.develooper.com> At 02:32 PM 22/04/2013, Indy Singh wrote: >Hi, > >Are you using Windows or Linux? > >If Windows, and if you want to start with a >working configuration and compare it with your >non-working configuration you can install IndigoAMPP from here: >http://www.indigostar.com/indigoampp.php > >This installation contains Apache, Perl, PHP and >MySQL. It???s a little out of date, but should be fine for your needs. > >Also note that on Windows your Perl scripts must >start with a line that points to the Perl installation, e.g: >#!C:\perl\bin\perl >or just: >#!perl > >Indy Singh >IndigoSTAR Software -- www.indigostar.com > Thanks Indy My issue is I have Apache installed in the C: drive and my application on the D: drive. I was hoping not to have to copy all the files (about 1 Gig) to the C: drive. I thought I could use the Options -Indexes FollowSymLinks AllowOverride None Order allow,deny Allow from all Options ExecCGI SetHandler cgi-script AddHandler cgi-script .pl .cgi The first one works - I can get the index.html page to come up the following page, a cgi script does not execute for some reason. I tested the Apache installation and a sample cgi script in the C:\Program Files\Apache Software Foundation\Apache2.2\cgi-bin directory does run. Perhaps it would be best to copy everything to C. I am also wondering if it would be better NOT to install Apache in the default Program Files location due to Windows permissions? Thanks all for your suggestions! >From: Chris Jones >Sent: Monday, April 22, 2013 2:13 PM >To: TPM >Subject: [tpm] Help with Apache configuration > >I am wondering if someone might be willing to >help me straighten out my httpd.conf file to get >a website on my local computer working. I have >succeeded in getting the first page, the >index.html page up but the subsequent cgi >scripts return an error. Or can you point me to >the approproate apache mailing list. > >Thank you! > > > >> >Christopher Jones, P.Eng. >Suite 1801, 1 Yonge Street >Toronto, ON M5E1W7 >Tel. 416-203-7465 >Fax. 416-946-1005 >email cj at enersave.ca > > >---------- >_______________________________________________ >toronto-pm mailing list >toronto-pm at pm.org >http://mail.pm.org/mailman/listinfo/toronto-pm >> Christopher Jones, P.Eng. Suite 1801, 1 Yonge Street Toronto, ON M5E1W7 Tel. 416-203-7465 Fax. 416-946-1005 email cj at enersave.ca -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at stok.ca Tue Apr 23 05:04:12 2013 From: mike at stok.ca (Mike Stok) Date: Tue, 23 Apr 2013 08:04:12 -0400 Subject: [tpm] Are we meeting this month? Message-ID: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> By my calendar we are due a meeting this Thursday. Do we have anything planned? Mike -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Henry.Baragar at Instantiated.Ca Tue Apr 23 13:49:22 2013 From: Henry.Baragar at Instantiated.Ca (Henry Baragar) Date: Tue, 23 Apr 2013 16:49:22 -0400 Subject: [tpm] Are we meeting this month? In-Reply-To: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> Message-ID: <5176F3D2.7050806@Instantiated.Ca> Mike, Due to the interest some members had in the Go language at the last meeting, I had mentioned that I could regurgitate the Go at Google: Language Design in the Service of Software Engineering keynote talk that Rob Pike resented at the SPLASH 2013 Conference. I prepared a slide deck before I left on vacation can could be ready for Thursday. Henry On 13-04-23 08:04 AM, Mike Stok wrote: > By my calendar we are due a meeting this Thursday. Do we have anything > planned? > > Mike > > -- > > Mike Stok > > http://www.stok.ca/~mike/ > > The "`Stok' disclaimers" apply. > > > > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- Henry Baragar Instantiated Software Inc. http://www.instantiated.ca 416-485-6343 x42 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Henry_Baragar.vcf Type: text/x-vcard Size: 159 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4279 bytes Desc: S/MIME Cryptographic Signature URL: From antoniosun at lavabit.com Tue Apr 23 14:56:39 2013 From: antoniosun at lavabit.com (Antonio Sun) Date: Tue, 23 Apr 2013 17:56:39 -0400 Subject: [tpm] Are we meeting this month? In-Reply-To: <5176F3D2.7050806@Instantiated.Ca> References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> <5176F3D2.7050806@Instantiated.Ca> Message-ID: On Tue, Apr 23, 2013 at 4:49 PM, Henry Baragar < Henry.Baragar at instantiated.ca> wrote: > > Due to the interest some members had in the Go language at the last > meeting, I had mentioned that I could regurgitate the Go at Google: > Language Design in the Service of Software Engineeringkeynote talk that Rob Pike resented at the SPLASH 2013 Conference. . . > Oh no, I can't make it this time -- I was the one who was interested in the Go language. I'll be really miss it. -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at stok.ca Tue Apr 23 21:06:14 2013 From: mike at stok.ca (Mike Stok) Date: Wed, 24 Apr 2013 00:06:14 -0400 Subject: [tpm] Are we meeting this month? In-Reply-To: <5176F3D2.7050806@Instantiated.Ca> References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> <5176F3D2.7050806@Instantiated.Ca> Message-ID: Thanks. Web site updated. Mike On 2013-04-23, at 4:49 PM, Henry Baragar wrote: > Mike, > > Due to the interest some members had in the Go language at the last meeting, I had mentioned that I could regurgitate the Go at Google: Language Design in the Service of Software Engineering keynote talk that Rob Pike resented at the SPLASH 2013 Conference. I prepared a slide deck before I left on vacation can could be ready for Thursday. > > Henry > > On 13-04-23 08:04 AM, Mike Stok wrote: >> By my calendar we are due a meeting this Thursday. Do we have anything planned? >> >> Mike >> >> -- >> >> Mike Stok >> http://www.stok.ca/~mike/ >> >> The "`Stok' disclaimers" apply. >> >> >> >> >> >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > > -- > Henry Baragar > Instantiated Software Inc. > http://www.instantiated.ca > 416-485-6343 x42 > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: From Henry.Baragar at Instantiated.Ca Wed Apr 24 09:13:11 2013 From: Henry.Baragar at Instantiated.Ca (Henry Baragar) Date: Wed, 24 Apr 2013 12:13:11 -0400 Subject: [tpm] Are we meeting this month? In-Reply-To: References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> <5176F3D2.7050806@Instantiated.Ca> Message-ID: <51780497.3080706@Instantiated.Ca> Just to be clear, Rob Pike will NOT be at the talk (not that he needs much of an introduction). Henry On 13-04-24 12:06 AM, Mike Stok wrote: > Thanks. > > Web site updated. > > Mike > > On 2013-04-23, at 4:49 PM, Henry Baragar > > > wrote: > >> Mike, >> >> Due to the interest some members had in the Go language at the last >> meeting, I had mentioned that I could regurgitate the Go at Google: >> Language Design in the Service of Software Engineering >> keynote >> talk that Rob Pike resented at the SPLASH 2013 Conference. I >> prepared a slide deck before I left on vacation can could be ready >> for Thursday. >> >> Henry >> >> On 13-04-23 08:04 AM, Mike Stok wrote: >>> By my calendar we are due a meeting this Thursday. Do we have >>> anything planned? >>> >>> Mike >>> >>> -- >>> >>> Mike Stok > >>> http://www.stok.ca/~mike/ >>> >>> The "`Stok' disclaimers" apply. >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> >> -- >> Henry Baragar >> Instantiated Software Inc. >> http://www.instantiated.ca >> 416-485-6343 x42 >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > -- > > Mike Stok > > http://www.stok.ca/~mike/ > > The "`Stok' disclaimers" apply. > > > > -- Henry Baragar Instantiated Software Inc. http://www.instantiated.ca 416-485-6343 x42 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Henry_Baragar.vcf Type: text/x-vcard Size: 159 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4279 bytes Desc: S/MIME Cryptographic Signature URL: From jbl at jbldata.com Thu Apr 25 08:10:58 2013 From: jbl at jbldata.com (J. Bobby Lopez) Date: Thu, 25 Apr 2013 11:10:58 -0400 Subject: [tpm] Are we meeting this month? In-Reply-To: References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> <5176F3D2.7050806@Instantiated.Ca> Message-ID: <51794782.30207@jbldata.com> I'll be there tonight, looking forward to the Google Go discussion. And a small tribute to fellow mongers: http://www.jbldata.com/just-another-perl-hacker/ On 13-04-24 12:06 AM, Mike Stok wrote: > Thanks. > > Web site updated. > > Mike > > On 2013-04-23, at 4:49 PM, Henry Baragar > > > wrote: > >> Mike, >> >> Due to the interest some members had in the Go language at the last >> meeting, I had mentioned that I could regurgitate the Go at Google: >> Language Design in the Service of Software Engineering >> keynote >> talk that Rob Pike resented at the SPLASH 2013 Conference. I >> prepared a slide deck before I left on vacation can could be ready >> for Thursday. >> >> Henry >> >> On 13-04-23 08:04 AM, Mike Stok wrote: >>> By my calendar we are due a meeting this Thursday. Do we have >>> anything planned? >>> >>> Mike >>> >>> -- >>> >>> Mike Stok > >>> http://www.stok.ca/~mike/ >>> >>> The "`Stok' disclaimers" apply. >>> >>> >>> >>> >>> >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> >> -- >> Henry Baragar >> Instantiated Software Inc. >> http://www.instantiated.ca >> 416-485-6343 x42 >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > -- > > Mike Stok > > http://www.stok.ca/~mike/ > > The "`Stok' disclaimers" apply. > > > > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From Henry.Baragar at Instantiated.Ca Thu Apr 25 14:07:52 2013 From: Henry.Baragar at Instantiated.Ca (Henry Baragar) Date: Thu, 25 Apr 2013 17:07:52 -0400 Subject: [tpm] Are we meeting this month? In-Reply-To: <51780497.3080706@Instantiated.Ca> References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> <5176F3D2.7050806@Instantiated.Ca> <51780497.3080706@Instantiated.Ca> Message-ID: <51799B28.5030904@Instantiated.Ca> Slides: * http://www.instantiated.ca/download/Go-design.pdf * http://www.instantiated.ca/download/Go-design.odp Cheers, Henry On 13-04-24 12:13 PM, Henry Baragar wrote: > Just to be clear, Rob Pike will NOT be at the talk (not that he needs > much of an introduction). > > Henry > > > On 13-04-24 12:06 AM, Mike Stok wrote: >> Thanks. >> >> Web site updated. >> >> Mike >> >> On 2013-04-23, at 4:49 PM, Henry Baragar >> > > wrote: >> >>> Mike, >>> >>> Due to the interest some members had in the Go language at the last >>> meeting, I had mentioned that I could regurgitate the Go at Google: >>> Language Design in the Service of Software Engineering >>> keynote >>> talk that Rob Pike resented at the SPLASH 2013 Conference. I >>> prepared a slide deck before I left on vacation can could be ready >>> for Thursday. >>> >>> Henry >>> >>> On 13-04-23 08:04 AM, Mike Stok wrote: >>>> By my calendar we are due a meeting this Thursday. Do we have >>>> anything planned? >>>> >>>> Mike >>>> >>>> -- >>>> >>>> Mike Stok > >>>> http://www.stok.ca/~mike/ >>>> >>>> The "`Stok' disclaimers" apply. >>>> >>>> >>>> >>>> >>>> >>>> >>>> _______________________________________________ >>>> toronto-pm mailing list >>>> toronto-pm at pm.org >>>> http://mail.pm.org/mailman/listinfo/toronto-pm >>> >>> >>> -- >>> Henry Baragar >>> Instantiated Software Inc. >>> http://www.instantiated.ca >>> 416-485-6343 x42 >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> -- >> >> Mike Stok > >> http://www.stok.ca/~mike/ >> >> The "`Stok' disclaimers" apply. >> >> >> >> > > > -- > Henry Baragar > Instantiated Software Inc. > http://www.instantiated.ca > 416-485-6343 x42 > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- Henry Baragar Instantiated Software Inc. http://www.instantiated.ca 416-485-6343 x42 -------------- next part -------------- An HTML attachment was scrubbed... URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: Henry_Baragar.vcf Type: text/x-vcard Size: 159 bytes Desc: not available URL: -------------- next part -------------- A non-text attachment was scrubbed... Name: smime.p7s Type: application/pkcs7-signature Size: 4279 bytes Desc: S/MIME Cryptographic Signature URL: From arocker at Vex.Net Fri Apr 26 14:03:44 2013 From: arocker at Vex.Net (arocker at Vex.Net) Date: Fri, 26 Apr 2013 17:03:44 -0400 Subject: [tpm] Plans In-Reply-To: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> Message-ID: Did last night's post-meeting produce a consensus of subjects for the next few meetings? From mike at stok.ca Sat Apr 27 18:49:21 2013 From: mike at stok.ca (Mike Stok) Date: Sat, 27 Apr 2013 21:49:21 -0400 Subject: [tpm] Plans In-Reply-To: References: <8567FF20-2457-49B9-86F5-F4F5FA32E478@stok.ca> Message-ID: I don't think anything concrete was agreed on, but there were a couple of useful discussions. Mike On 2013-04-26, at 5:03 PM, arocker at Vex.Net wrote: > > Did last night's post-meeting produce a consensus of subjects for the next > few meetings? > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. From arocker at Vex.Net Sun Apr 28 08:19:41 2013 From: arocker at Vex.Net (arocker at Vex.Net) Date: Sun, 28 Apr 2013 11:19:41 -0400 Subject: [tpm] Plans Message-ID: > I don't think anything concrete was agreed on, but there were a couple of > useful discussions. > We really should have something decided. It takes time to put together a worthwhile presentation, and we look amateurish if we can't name the topic until the previous Wednesday. It would be nice to have at least 3 months planned. What were the suggestions? From indy at indigostar.com Mon Apr 29 08:09:15 2013 From: indy at indigostar.com (Indy Singh) Date: Mon, 29 Apr 2013 11:09:15 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: Message-ID: <1B2B0FF121A44411A4A077551C1080DF@indy> Hi All, What is a good way to match a string that may appear at the start or middle or end of a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. Example: my $s = 'foo,bar,boo,baz'; my ($match) = $s =~ /(foo)/; I am looking to match the following: The start of a string or a separator followed by A specified string followed by A separator or the end of the string What are the extra things I need to surround the match expression? One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? Indy Singh IndigoSTAR Software -- www.indigostar.com From mattp at cpan.org Mon Apr 29 08:14:18 2013 From: mattp at cpan.org (Matthew Phillips) Date: Mon, 29 Apr 2013 11:14:18 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <1B2B0FF121A44411A4A077551C1080DF@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: Hi, Maybe 'if ('foo,bar,boo,baz' =~ /,?foo,?/) { ... } ' is what you're looking for. Cheers, Matt On Mon, Apr 29, 2013 at 11:09 AM, Indy Singh wrote: > Hi All, > > What is a good way to match a string that may appear at the start or > middle or end of a list. I have stumbled along and made this work in the > past, now I am looking for the clean and proper way to do it. > > > Example: > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /(foo)/; > > I am looking to match the following: > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > What are the extra things I need to surround the match expression? > > One of the unpleasant side effects of putting a list with alternatives at > the start .e.g. '(^|,)' , is that it creates an undesired capture string. > Is it possible to avoid creating the capture string? > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > > ______________________________**_________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/**listinfo/toronto-pm > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at stok.ca Mon Apr 29 08:15:01 2013 From: mike at stok.ca (Mike Stok) Date: Mon, 29 Apr 2013 11:15:01 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <1B2B0FF121A44411A4A077551C1080DF@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: <74150F24-25AA-4CA8-A3FD-327B416479A6@stok.ca> Do you need to match or could you just split the list and see if any of the elements are what you want? Mike On 2013-04-29, at 11:09 AM, "Indy Singh" wrote: > Hi All, > > What is a good way to match a string that may appear at the start or middle or end of a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. > > > Example: > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /(foo)/; > > I am looking to match the following: > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > What are the extra things I need to surround the match expression? > > One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. From indy at indigostar.com Mon Apr 29 08:16:39 2013 From: indy at indigostar.com (Indy Singh) Date: Mon, 29 Apr 2013 11:16:39 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <74150F24-25AA-4CA8-A3FD-327B416479A6@stok.ca> References: <1B2B0FF121A44411A4A077551C1080DF@indy> <74150F24-25AA-4CA8-A3FD-327B416479A6@stok.ca> Message-ID: <548490E96F18426294F9F061FB1083F4@indy> Splitting is an option, but I am looking to minimize the amount of code. So in this case I am looking to match only. Indy Singh IndigoSTAR Software -- www.indigostar.com -----Original Message----- From: Mike Stok Sent: Monday, April 29, 2013 11:15 AM To: Indy Singh Cc: Toronto PerlMongers Subject: Re: [tpm] String matching at start or middle or end of list Do you need to match or could you just split the list and see if any of the elements are what you want? Mike On 2013-04-29, at 11:09 AM, "Indy Singh" wrote: > Hi All, > > What is a good way to match a string that may appear at the start or middle or end of a list. I have stumbled along and made this > work in the past, now I am looking for the clean and proper way to do it. > > > Example: > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /(foo)/; > > I am looking to match the following: > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > What are the extra things I need to surround the match expression? > > One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an > undesired capture string. Is it possible to avoid creating the capture string? > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. From jbl at jbldata.com Mon Apr 29 08:18:02 2013 From: jbl at jbldata.com (J. Bobby Lopez) Date: Mon, 29 Apr 2013 11:18:02 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <1B2B0FF121A44411A4A077551C1080DF@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: <517E8F2A.1060801@jbldata.com> Would this work for your purposes?: my $s = 'foo,bar,boo,baz'; my ($match) = $s =~ /[,]*foo[,]*/; On 13-04-29 11:09 AM, Indy Singh wrote: > Hi All, > > What is a good way to match a string that may appear at the start or > middle or end of a list. I have stumbled along and made this work in > the past, now I am looking for the clean and proper way to do it. > > > Example: > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /(foo)/; > > I am looking to match the following: > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > What are the extra things I need to surround the match expression? > > One of the unpleasant side effects of putting a list with alternatives > at the start .e.g. '(^|,)' , is that it creates an undesired capture > string. Is it possible to avoid creating the capture string? > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From indy at indigostar.com Mon Apr 29 08:18:24 2013 From: indy at indigostar.com (Indy Singh) Date: Mon, 29 Apr 2013 11:18:24 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: <415EED0C6E614DC0A15A27281A4B274B@indy> I want to extract the matched string into a variable. e.g. my ($match) = something Indy Singh IndigoSTAR Software -- www.indigostar.com From: Matthew Phillips Sent: Monday, April 29, 2013 11:14 AM To: Indy Singh Cc: Toronto PerlMongers Subject: Re: [tpm] String matching at start or middle or end of list Hi, Maybe 'if ('foo,bar,boo,baz' =~ /,?foo,?/) { ... } ' is what you're looking for. Cheers, Matt On Mon, Apr 29, 2013 at 11:09 AM, Indy Singh wrote: Hi All, What is a good way to match a string that may appear at the start or middle or end of a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. Example: my $s = 'foo,bar,boo,baz'; my ($match) = $s =~ /(foo)/; I am looking to match the following: The start of a string or a separator followed by A specified string followed by A separator or the end of the string What are the extra things I need to surround the match expression? One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? Indy Singh IndigoSTAR Software -- www.indigostar.com _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From indy at indigostar.com Mon Apr 29 08:24:52 2013 From: indy at indigostar.com (Indy Singh) Date: Mon, 29 Apr 2013 11:24:52 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <517E8F2A.1060801@jbldata.com> References: <1B2B0FF121A44411A4A077551C1080DF@indy> <517E8F2A.1060801@jbldata.com> Message-ID: This fails for the following case: my $s = 'food,bar,baz'; my ($match) = $s =~ /[,]*(foo)[,]*/; print "match=$match\n"; In this case 'foo' matches, but is not a valid match. Only 'food' is a valid match. Indy Singh IndigoSTAR Software -- www.indigostar.com -----Original Message----- From: J. Bobby Lopez Sent: Monday, April 29, 2013 11:18 AM To: toronto-pm at pm.org Subject: Re: [tpm] String matching at start or middle or end of list Would this work for your purposes?: my $s = 'foo,bar,boo,baz'; my ($match) = $s =~ /[,]*foo[,]*/; On 13-04-29 11:09 AM, Indy Singh wrote: > Hi All, > > What is a good way to match a string that may appear at the start or > middle or end of a list. I have stumbled along and made this work in > the past, now I am looking for the clean and proper way to do it. > > > Example: > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /(foo)/; > > I am looking to match the following: > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > What are the extra things I need to surround the match expression? > > One of the unpleasant side effects of putting a list with alternatives > at the start .e.g. '(^|,)' , is that it creates an undesired capture > string. Is it possible to avoid creating the capture string? > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm _______________________________________________ toronto-pm mailing list toronto-pm at pm.org http://mail.pm.org/mailman/listinfo/toronto-pm From jbl at jbldata.com Mon Apr 29 08:28:13 2013 From: jbl at jbldata.com (J. Bobby Lopez) Date: Mon, 29 Apr 2013 11:28:13 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <415EED0C6E614DC0A15A27281A4B274B@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> <415EED0C6E614DC0A15A27281A4B274B@indy> Message-ID: <517E918D.9020305@jbldata.com> You'd have to use () to get the back-reference, so using Mike's suggestion it would be: ------- use feature say; my $s = 'foo,bar,boo,baz'; my $match; if ( ($match) = 'foo,bar,boo,baz' =~ /,?(foo),?/) { say $match } ------- Or mine.. ------- use feature say; my $s = 'foo,bar,boo,baz'; my $match; if ( ($match) = 'foo,bar,boo,baz' =~ /[,]*(foo)[,]*/) { say $match } ------- Unless of course I'm missing some other requirement/restriction. On 13-04-29 11:18 AM, Indy Singh wrote: > I want to extract the matched string into a variable. > e.g. > my ($match) = something > Indy Singh > IndigoSTAR Software -- www.indigostar.com > *From:* Matthew Phillips > *Sent:* Monday, April 29, 2013 11:14 AM > *To:* Indy Singh > *Cc:* Toronto PerlMongers > *Subject:* Re: [tpm] String matching at start or middle or end of list > Hi, > Maybe 'if ('foo,bar,boo,baz' =~ /,?foo,?/) { ... } ' is what you're > looking for. > > Cheers, > Matt > > On Mon, Apr 29, 2013 at 11:09 AM, Indy Singh > wrote: > > Hi All, > > What is a good way to match a string that may appear at the start > or middle or end of a list. I have stumbled along and made this > work in the past, now I am looking for the clean and proper way to > do it. > > > Example: > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /(foo)/; > > I am looking to match the following: > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > What are the extra things I need to surround the match expression? > > One of the unpleasant side effects of putting a list with > alternatives at the start .e.g. '(^|,)' , is that it creates an > undesired capture string. Is it possible to avoid creating the > capture string? > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From jbl at jbldata.com Mon Apr 29 08:33:42 2013 From: jbl at jbldata.com (J. Bobby Lopez) Date: Mon, 29 Apr 2013 11:33:42 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: <1B2B0FF121A44411A4A077551C1080DF@indy> <517E8F2A.1060801@jbldata.com> Message-ID: <517E92D6.2040503@jbldata.com> Ah, I think I got blind-sided by 'food' instead of 'foo'. Now I'm hungry. How about this?: ---- use feature say; my $match; if ( ($match) = 'food,bar,boo,baz' =~ /[,]*(foo\w?)[,]*/) { say $match } ---- On 13-04-29 11:24 AM, Indy Singh wrote: > This fails for the following case: > my $s = 'food,bar,baz'; > my ($match) = $s =~ /[,]*(foo)[,]*/; > print "match=$match\n"; > > In this case 'foo' matches, but is not a valid match. Only 'food' is a > valid match. > > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > -----Original Message----- From: J. Bobby Lopez Sent: Monday, April > 29, 2013 11:18 AM To: toronto-pm at pm.org Subject: Re: [tpm] String > matching at start or middle or end of list > Would this work for your purposes?: > > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /[,]*foo[,]*/; > > > On 13-04-29 11:09 AM, Indy Singh wrote: >> Hi All, >> >> What is a good way to match a string that may appear at the start or >> middle or end of a list. I have stumbled along and made this work in >> the past, now I am looking for the clean and proper way to do it. >> >> >> Example: >> my $s = 'foo,bar,boo,baz'; >> my ($match) = $s =~ /(foo)/; >> >> I am looking to match the following: >> The start of a string or a separator followed by >> A specified string followed by >> A separator or the end of the string >> >> What are the extra things I need to surround the match expression? >> >> One of the unpleasant side effects of putting a list with >> alternatives at the start .e.g. '(^|,)' , is that it creates an >> undesired capture string. Is it possible to avoid creating the >> capture string? >> >> Indy Singh >> IndigoSTAR Software -- www.indigostar.com >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From antoniosun at lavabit.com Mon Apr 29 08:36:56 2013 From: antoniosun at lavabit.com (Antonio Sun) Date: Mon, 29 Apr 2013 11:36:56 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <517E8F2A.1060801@jbldata.com> References: <1B2B0FF121A44411A4A077551C1080DF@indy> <517E8F2A.1060801@jbldata.com> Message-ID: On Mon, Apr 29, 2013 at 11:18 AM, J. Bobby Lopez wrote: > Would this work for your purposes?: > > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /[,]*foo[,]*/; That'd cast the net too wide for thing like: ' foobar,' I am looking to match the following: > > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > > I want to extract the matched string into a variable. How about doing it separately: $s =~ /^(foo),|,(foo),|,(foo)$/; my ($match) = $1; HTH Antonio -------------- next part -------------- An HTML attachment was scrubbed... URL: From indy at indigostar.com Mon Apr 29 08:42:01 2013 From: indy at indigostar.com (Indy Singh) Date: Mon, 29 Apr 2013 11:42:01 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <517E92D6.2040503@jbldata.com> References: <1B2B0FF121A44411A4A077551C1080DF@indy> <517E8F2A.1060801@jbldata.com> <517E92D6.2040503@jbldata.com> Message-ID: <299258B123294BAB87CA28341071FC75@indy> It still matches food. The string to match may or may not end on a word boundary. -----Original Message----- From: J. Bobby Lopez Sent: Monday, April 29, 2013 11:33 AM To: Indy Singh Cc: toronto-pm at pm.org Subject: Re: [tpm] String matching at start or middle or end of list Ah, I think I got blind-sided by 'food' instead of 'foo'. Now I'm hungry. How about this?: ---- use feature say; my $match; if ( ($match) = 'food,bar,boo,baz' =~ /[,]*(foo\w?)[,]*/) { say $match } ---- On 13-04-29 11:24 AM, Indy Singh wrote: > This fails for the following case: > my $s = 'food,bar,baz'; > my ($match) = $s =~ /[,]*(foo)[,]*/; > print "match=$match\n"; > > In this case 'foo' matches, but is not a valid match. Only 'food' is a > valid match. > > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > -----Original Message----- From: J. Bobby Lopez Sent: Monday, April > 29, 2013 11:18 AM To: toronto-pm at pm.org Subject: Re: [tpm] String > matching at start or middle or end of list > Would this work for your purposes?: > > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /[,]*foo[,]*/; > > > On 13-04-29 11:09 AM, Indy Singh wrote: >> Hi All, >> >> What is a good way to match a string that may appear at the start or >> middle or end of a list. I have stumbled along and made this work in >> the past, now I am looking for the clean and proper way to do it. >> >> >> Example: >> my $s = 'foo,bar,boo,baz'; >> my ($match) = $s =~ /(foo)/; >> >> I am looking to match the following: >> The start of a string or a separator followed by >> A specified string followed by >> A separator or the end of the string >> >> What are the extra things I need to surround the match expression? >> >> One of the unpleasant side effects of putting a list with >> alternatives at the start .e.g. '(^|,)' , is that it creates an >> undesired capture string. Is it possible to avoid creating the >> capture string? >> >> Indy Singh >> IndigoSTAR Software -- www.indigostar.com >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm From jbl at jbldata.com Mon Apr 29 08:54:38 2013 From: jbl at jbldata.com (J. Bobby Lopez) Date: Mon, 29 Apr 2013 11:54:38 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <299258B123294BAB87CA28341071FC75@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> <517E8F2A.1060801@jbldata.com> <517E92D6.2040503@jbldata.com> <299258B123294BAB87CA28341071FC75@indy> Message-ID: <517E97BE.2070405@jbldata.com> In that case you'll likely need to split on the delimeter [,] On 13-04-29 11:42 AM, Indy Singh wrote: > It still matches food. The string to match may or may not end on a > word boundary. > > -----Original Message----- From: J. Bobby Lopez Sent: Monday, April > 29, 2013 11:33 AM To: Indy Singh Cc: toronto-pm at pm.org Subject: Re: > [tpm] String matching at start or middle or end of list > Ah, I think I got blind-sided by 'food' instead of 'foo'. Now I'm > hungry. > > > How about this?: > ---- > use feature say; > my $match; > > if ( ($match) = 'food,bar,boo,baz' =~ /[,]*(foo\w?)[,]*/) { say $match } > ---- > > > > On 13-04-29 11:24 AM, Indy Singh wrote: >> This fails for the following case: >> my $s = 'food,bar,baz'; >> my ($match) = $s =~ /[,]*(foo)[,]*/; >> print "match=$match\n"; >> >> In this case 'foo' matches, but is not a valid match. Only 'food' is >> a valid match. >> >> >> Indy Singh >> IndigoSTAR Software -- www.indigostar.com >> -----Original Message----- From: J. Bobby Lopez Sent: Monday, April >> 29, 2013 11:18 AM To: toronto-pm at pm.org Subject: Re: [tpm] String >> matching at start or middle or end of list >> Would this work for your purposes?: >> >> my $s = 'foo,bar,boo,baz'; >> my ($match) = $s =~ /[,]*foo[,]*/; >> >> >> On 13-04-29 11:09 AM, Indy Singh wrote: >>> Hi All, >>> >>> What is a good way to match a string that may appear at the start or >>> middle or end of a list. I have stumbled along and made this work >>> in the past, now I am looking for the clean and proper way to do it. >>> >>> >>> Example: >>> my $s = 'foo,bar,boo,baz'; >>> my ($match) = $s =~ /(foo)/; >>> >>> I am looking to match the following: >>> The start of a string or a separator followed by >>> A specified string followed by >>> A separator or the end of the string >>> >>> What are the extra things I need to surround the match expression? >>> >>> One of the unpleasant side effects of putting a list with >>> alternatives at the start .e.g. '(^|,)' , is that it creates an >>> undesired capture string. Is it possible to avoid creating the >>> capture string? >>> >>> Indy Singh >>> IndigoSTAR Software -- www.indigostar.com >>> >>> _______________________________________________ >>> toronto-pm mailing list >>> toronto-pm at pm.org >>> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > From mike at stok.ca Mon Apr 29 08:56:37 2013 From: mike at stok.ca (Mike Stok) Date: Mon, 29 Apr 2013 11:56:37 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <548490E96F18426294F9F061FB1083F4@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> <74150F24-25AA-4CA8-A3FD-327B416479A6@stok.ca> <548490E96F18426294F9F061FB1083F4@indy> Message-ID: In terms of clarity I think that splitting the concerns doesn't add that much code @list = split /,/, $s; @matches = grep { $_ =~ /\Afoo\z/ } @list; @list could be eliminated if you like. Mike On 2013-04-29, at 11:16 AM, "Indy Singh" wrote: > Splitting is an option, but I am looking to minimize the amount of code. So in this case I am looking to match only. > > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > -----Original Message----- From: Mike Stok > Sent: Monday, April 29, 2013 11:15 AM > To: Indy Singh > Cc: Toronto PerlMongers > Subject: Re: [tpm] String matching at start or middle or end of list > > Do you need to match or could you just split the list and see if any of the elements are what you want? > > Mike > > On 2013-04-29, at 11:09 AM, "Indy Singh" wrote: > >> Hi All, >> >> What is a good way to match a string that may appear at the start or middle or end of a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. >> >> >> Example: >> my $s = 'foo,bar,boo,baz'; >> my ($match) = $s =~ /(foo)/; >> >> I am looking to match the following: >> The start of a string or a separator followed by >> A specified string followed by >> A separator or the end of the string >> >> What are the extra things I need to surround the match expression? >> >> One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? >> >> Indy Singh >> IndigoSTAR Software -- www.indigostar.com >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > -- > > Mike Stok > http://www.stok.ca/~mike/ > > The "`Stok' disclaimers" apply. > > > -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. From shlomif at shlomifish.org Mon Apr 29 09:05:30 2013 From: shlomif at shlomifish.org (Shlomi Fish) Date: Mon, 29 Apr 2013 19:05:30 +0300 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <1B2B0FF121A44411A4A077551C1080DF@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: <20130429190530.0cd27f46@telaviv1.shlomifish.org> Hi Indy (and all), On Mon, 29 Apr 2013 11:09:15 -0400 "Indy Singh" wrote: > Hi All, > > What is a good way to match a string that may appear at the start or middle > or end of a list. I have stumbled along and made this work in the past, now > I am looking for the clean and proper way to do it. > > > Example: > my $s = 'foo,bar,boo,baz'; > my ($match) = $s =~ /(foo)/; > > I am looking to match the following: > The start of a string or a separator followed by > A specified string followed by > A separator or the end of the string > > What are the extra things I need to surround the match expression? > > One of the unpleasant side effects of putting a list with alternatives at the > start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it > possible to avoid creating the capture string? > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Perl Humour - http://perl-begin.org/humour/ Real programmers don?t write workarounds. They tell their users to upgrade their software. Please reply to list if it's a mailing list post - http://shlom.in/reply . From shlomif at shlomifish.org Mon Apr 29 09:08:08 2013 From: shlomif at shlomifish.org (Shlomi Fish) Date: Mon, 29 Apr 2013 19:08:08 +0300 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <1B2B0FF121A44411A4A077551C1080DF@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: <20130429190808.5f51a57e@telaviv1.shlomifish.org> Hi Indy (and all), Please don't start a new thread by replying to an existing message and then changing the subject line and entering a new body. If you still do so, then threaded mailers show it under the thread. Instead, writing a new message to toronoto-pm at pm.org . [Also, please reply to all recipients.] Regards, Shlomi Fish [SNIPPED] -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "Humanity" - Parody of Modern Life - http://shlom.in/humanity Chuck Norris refactors 10 million lines of Perl code before lunch. ? http://www.shlomifish.org/humour/bits/facts/Chuck-Norris/ Please reply to list if it's a mailing list post - http://shlom.in/reply . From shlomif at shlomifish.org Mon Apr 29 09:12:16 2013 From: shlomif at shlomifish.org (Shlomi Fish) Date: Mon, 29 Apr 2013 19:12:16 +0300 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: <20130429191216.2249e45c@telaviv1.shlomifish.org> Hi, On Mon, 29 Apr 2013 11:14:18 -0400 Matthew Phillips wrote: > Hi, > Maybe 'if ('foo,bar,boo,baz' =~ /,?foo,?/) { ... } ' is what you're looking > for. That's effectively equivalent to to ?=~ /foo/? which will also match against the string "matchmefoobar,hello,there". You want: [QUOTE] shlomif at telaviv1:~$ perl -dE 24 Loading DB routines from perl5db.pl version 1.37 Editor support available. Enter h or 'h h' for help, or 'man perldebug' for more help. main::(-e:1): 24 DB<264> x ('foo,bar,boo,baz' =~ /(?:\A|,)foo(?:,|\z)/) 0 1 DB<265> x (('foo,bar,boo,baz' =~ /(?:\A|,)foo(?:,|\z)/) ? "Y" : "N") 0 'Y' DB<266> x (('foop,bar,boo,baz' =~ /(?:\A|,)foo(?:,|\z)/) ? "Y" : "N") 0 'N' DB<267> x (('foo,bar,boo,baz' =~ /(?:\A|,)foo(?:,|\z)/) ? "Y" : "N") 0 'Y' DB<268> x (('fop,bar,boo,baz' =~ /(?:\A|,)foo(?:,|\z)/) ? "Y" : "N") 0 'N' DB<269> x (('fop,bar,foo,baz' =~ /(?:\A|,)foo(?:,|\z)/) ? "Y" : "N") 0 'Y' DB<270> x (('fop,bar,baam,foo' =~ /(?:\A|,)foo(?:,|\z)/) ? "Y" : "N") 0 'Y' DB<271> x (('fop,bar,foorty,baz' =~ /(?:\A|,)foo(?:,|\z)/) ? "Y" : "N") 0 'N' DB<272> [/QUOTE] Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Why I Love Perl - http://shlom.in/joy-of-perl Larry Wall is lazy, impatient and full of hubris. Please reply to list if it's a mailing list post - http://shlom.in/reply . From shlomif at shlomifish.org Mon Apr 29 09:13:59 2013 From: shlomif at shlomifish.org (Shlomi Fish) Date: Mon, 29 Apr 2013 19:13:59 +0300 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: <1B2B0FF121A44411A4A077551C1080DF@indy> <74150F24-25AA-4CA8-A3FD-327B416479A6@stok.ca> <548490E96F18426294F9F061FB1083F4@indy> Message-ID: <20130429191359.2d8141a6@telaviv1.shlomifish.org> Hi Mike, On Mon, 29 Apr 2013 11:56:37 -0400 Mike Stok wrote: > In terms of clarity I think that splitting the concerns doesn't add that much > code > > @list = split /,/, $s; > @matches = grep { $_ =~ /\Afoo\z/ } @list; ?$_ =~ /\Afoo\z/? can also be written as ?/\Afoo\z/? or better yet as ?$_ eq 'foo'?. Regards, Shlomi Fish > > @list could be eliminated if you like. > > Mike > -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Original Riddles - http://www.shlomifish.org/puzzles/ There?s no point in keeping an idea to yourself since there?s a 10 to 1 chance that somebody already has it and will share it before you. Please reply to list if it's a mailing list post - http://shlom.in/reply . From shlomif at shlomifish.org Mon Apr 29 09:16:31 2013 From: shlomif at shlomifish.org (Shlomi Fish) Date: Mon, 29 Apr 2013 19:16:31 +0300 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: <1B2B0FF121A44411A4A077551C1080DF@indy> <517E8F2A.1060801@jbldata.com> Message-ID: <20130429191631.10403e4b@telaviv1.shlomifish.org> Hi Antonio, On Mon, 29 Apr 2013 11:36:56 -0400 Antonio Sun wrote: > On Mon, Apr 29, 2013 at 11:18 AM, J. Bobby Lopez wrote: > > > > Would this work for your purposes?: > > > > my $s = 'foo,bar,boo,baz'; > > my ($match) = $s =~ /[,]*foo[,]*/; > > > That'd cast the net too wide for thing like: ' foobar,' > > I am looking to match the following: > > > > The start of a string or a separator followed by > > A specified string followed by > > A separator or the end of the string > > > > > > > I want to extract the matched string into a variable. > > > How about doing it separately: > > $s =~ /^(foo),|,(foo),|,(foo)$/; > my ($match) = $1; 1. This won't match if foo is the second or third capture. 2. What happens if $s eq 'foo' (and contains no commas)? See my response for more information. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ What does "Zionism" mean? - http://shlom.in/def-zionism Satan condemned Hitler for a million years of writing XSLT. ? http://www.shlomifish.org/humour/bits/facts/XSLT/ Please reply to list if it's a mailing list post - http://shlom.in/reply . From arocker at Vex.Net Mon Apr 29 10:13:17 2013 From: arocker at Vex.Net (arocker at Vex.Net) Date: Mon, 29 Apr 2013 13:13:17 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <1B2B0FF121A44411A4A077551C1080DF@indy> References: <1B2B0FF121A44411A4A077551C1080DF@indy> Message-ID: <347e8328b0d065d30ae72256a70cf598.squirrel@mail.vex.net> > > What is a good way to match a string that may appear at the start or > middle or end of a list. I'm not sure if I'm being dim here, but I think a more comprehensive set of cases, (matching & non-matching), would be helpful here. That would let people test their "solutions" before proposing them. From indy at indigostar.com Mon Apr 29 10:52:34 2013 From: indy at indigostar.com (Indy Singh) Date: Mon, 29 Apr 2013 13:52:34 -0400 Subject: [tpm] String matching at start or middle or end of list Message-ID: <5C25346BCE1340C098122D68EE1AACD1@indy> Hi All, Following Alans suggestion, I am going to repost the question with some test cases. I am looking for a way to match a string that appears in a comma separated list. The string may may appear at the start or middle, end or nowhere on a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? Test code below. Anywhere where ?foo? appears should match but ?food? should not match foreach $s ('foo,bar,baz', 'bar,foo,baz', 'bar,baz,foo', 'bar,food,baz') { print "s=$s "; my ($match) = $s =~ /some reg expression or perl code here to match foo/; if ($match) { print "match=$match\n"; } else { print "no match\n"; } } Indy Singh IndigoSTAR Software -- www.indigostar.com -------------- next part -------------- An HTML attachment was scrubbed... URL: From stuart at morungos.com Mon Apr 29 11:00:30 2013 From: stuart at morungos.com (Stuart Watt) Date: Mon, 29 Apr 2013 14:00:30 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <5C25346BCE1340C098122D68EE1AACD1@indy> References: <5C25346BCE1340C098122D68EE1AACD1@indy> Message-ID: <6956D526-8B38-490B-8D83-2041FFE92ED6@morungos.com> I've used \b for this. i.e., /\bfoo\b/ - the \b is a zero-width word/nonword boundary, and I use it a lot to anchor at separators. All the best Stuart On 2013-04-29, at 1:52 PM, Indy Singh wrote: > Hi All, > > Following Alans suggestion, I am going to repost the question with some test cases. > > I am looking for a way to match a string that appears in a comma separated list. The string may may appear at the start or middle, end or nowhere on a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. > > One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? > > Test code below. Anywhere where ?foo? appears should match but ?food? should not match > > foreach $s ('foo,bar,baz', 'bar,foo,baz', 'bar,baz,foo', 'bar,food,baz') { > print "s=$s "; > > my ($match) = $s =~ /some reg expression or perl code here to match foo/; > > if ($match) { > print "match=$match\n"; > } else { > print "no match\n"; > } > } > > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -------------- next part -------------- An HTML attachment was scrubbed... URL: From antoniosun at lavabit.com Mon Apr 29 11:17:53 2013 From: antoniosun at lavabit.com (Antonio Sun) Date: Mon, 29 Apr 2013 14:17:53 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <6956D526-8B38-490B-8D83-2041FFE92ED6@morungos.com> References: <5C25346BCE1340C098122D68EE1AACD1@indy> <6956D526-8B38-490B-8D83-2041FFE92ED6@morungos.com> Message-ID: that'll match cases like, bar,and foo etc,baz I'm still think my answer is the closest, given what's required in OP. On Mon, Apr 29, 2013 at 2:00 PM, Stuart Watt wrote: > I've used \b for this. i.e., /\bfoo\b/ - the \b is a zero-width > word/nonword boundary, and I use it a lot to anchor at separators. > > All the best > Stuart > > > On 2013-04-29, at 1:52 PM, Indy Singh wrote: > > Hi All, > > Following Alans suggestion, I am going to repost the question with some > test cases. > > I am looking for a way to match a string that appears in a comma separated > list. The string may may appear at the start or middle, end or nowhere on a > list. I have stumbled along and made this work in the past, now I am > looking for the clean and proper way to do it. > > One of the unpleasant side effects of putting a list with alternatives at > the start .e.g. '(^|,)' , is that it creates an undesired capture string. > Is it possible to avoid creating the capture string? > > Test code below. Anywhere where ?foo? appears should match but ?food? > should not match > > foreach $s ('foo,bar,baz', 'bar,foo,baz', 'bar,baz,foo', 'bar,food,baz') { > print "s=$s "; > > my ($match) = $s =~ /some reg expression or perl code here to match > foo/; > > if ($match) { > print "match=$match\n"; > } else { > print "no match\n"; > } > } > > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From quantum.mechanic.1964 at gmail.com Mon Apr 29 11:25:53 2013 From: quantum.mechanic.1964 at gmail.com (Kwan Tamakanic) Date: Mon, 29 Apr 2013 19:25:53 +0100 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: <5C25346BCE1340C098122D68EE1AACD1@indy> <6956D526-8B38-490B-8D83-2041FFE92ED6@morungos.com> Message-ID: say 'foo,bar,baz' =~ /(?:^|,)(foo)(,|$)/ > foo say 'bar,foo,baz' =~ /(?:^|,)(foo)(,|$)/ > foo say 'bar,baz,foo' =~ /(?:^|,)(foo)(,|$)/ > foo The regex is generally cleaner if you use \b instead of the other bits, assuming that meets your requirements. (?:...) is a non-capturing group, which is useful for delimiting alternations or applying quantifiers. It must be Monday, because everyone seems to be struggling with this. ?:^/ -QM On Mon, Apr 29, 2013 at 7:17 PM, Antonio Sun wrote: > that'll match cases like, > > bar,and foo etc,baz > > I'm still think my answer is the closest, given what's required in OP. > > > On Mon, Apr 29, 2013 at 2:00 PM, Stuart Watt wrote: > >> I've used \b for this. i.e., /\bfoo\b/ - the \b is a zero-width >> word/nonword boundary, and I use it a lot to anchor at separators. >> >> All the best >> Stuart >> >> >> On 2013-04-29, at 1:52 PM, Indy Singh wrote: >> >> Hi All, >> >> Following Alans suggestion, I am going to repost the question with some >> test cases. >> >> I am looking for a way to match a string that appears in a comma >> separated list. The string may may appear at the start or middle, end or >> nowhere on a list. I have stumbled along and made this work in the past, >> now I am looking for the clean and proper way to do it. >> >> One of the unpleasant side effects of putting a list with alternatives at >> the start .e.g. '(^|,)' , is that it creates an undesired capture string. >> Is it possible to avoid creating the capture string? >> >> Test code below. Anywhere where ?foo? appears should match but ?food? >> should not match >> >> foreach $s ('foo,bar,baz', 'bar,foo,baz', 'bar,baz,foo', 'bar,food,baz') { >> print "s=$s "; >> >> my ($match) = $s =~ /some reg expression or perl code here to match >> foo/; >> >> if ($match) { >> print "match=$match\n"; >> } else { >> print "no match\n"; >> } >> } >> >> >> Indy Singh >> IndigoSTAR Software -- www.indigostar.com >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> >> >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm >> >> > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -- -QM Quantum Mechanics: The dreams stuff is made of -------------- next part -------------- An HTML attachment was scrubbed... URL: From stuart at morungos.com Mon Apr 29 11:38:20 2013 From: stuart at morungos.com (Stuart Watt) Date: Mon, 29 Apr 2013 14:38:20 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: References: <5C25346BCE1340C098122D68EE1AACD1@indy> <6956D526-8B38-490B-8D83-2041FFE92ED6@morungos.com> Message-ID: The other simple solution is: my ($match) = ",$s," =~ m/,foo,/; --S On 2013-04-29, at 2:17 PM, Antonio Sun wrote: > that'll match cases like, > > bar,and foo etc,baz > > I'm still think my answer is the closest, given what's required in OP. > > > On Mon, Apr 29, 2013 at 2:00 PM, Stuart Watt wrote: > I've used \b for this. i.e., /\bfoo\b/ - the \b is a zero-width word/nonword boundary, and I use it a lot to anchor at separators. > > All the best > Stuart > > > On 2013-04-29, at 1:52 PM, Indy Singh wrote: > >> Hi All, >> >> Following Alans suggestion, I am going to repost the question with some test cases. >> >> I am looking for a way to match a string that appears in a comma separated list. The string may may appear at the start or middle, end or nowhere on a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. >> >> One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? >> >> Test code below. Anywhere where ?foo? appears should match but ?food? should not match >> >> foreach $s ('foo,bar,baz', 'bar,foo,baz', 'bar,baz,foo', 'bar,food,baz') { >> print "s=$s "; >> >> my ($match) = $s =~ /some reg expression or perl code here to match foo/; >> >> if ($match) { >> print "match=$match\n"; >> } else { >> print "no match\n"; >> } >> } >> >> >> Indy Singh >> IndigoSTAR Software -- www.indigostar.com >> _______________________________________________ >> toronto-pm mailing list >> toronto-pm at pm.org >> http://mail.pm.org/mailman/listinfo/toronto-pm > > > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm > > -------------- next part -------------- An HTML attachment was scrubbed... URL: From mike at stok.ca Mon Apr 29 11:47:10 2013 From: mike at stok.ca (Mike Stok) Date: Mon, 29 Apr 2013 14:47:10 -0400 Subject: [tpm] String matching at start or middle or end of list In-Reply-To: <5C25346BCE1340C098122D68EE1AACD1@indy> References: <5C25346BCE1340C098122D68EE1AACD1@indy> Message-ID: On 2013-04-29, at 1:52 PM, "Indy Singh" wrote: > Hi All, > > Following Alans suggestion, I am going to repost the question with some test cases. > > I am looking for a way to match a string that appears in a comma separated list. The string may may appear at the start or middle, end or nowhere on a list. I have stumbled along and made this work in the past, now I am looking for the clean and proper way to do it. > > One of the unpleasant side effects of putting a list with alternatives at the start .e.g. '(^|,)' , is that it creates an undesired capture string. Is it possible to avoid creating the capture string? > > Test code below. Anywhere where ?foo? appears should match but ?food? should not match > > foreach $s ('foo,bar,baz', 'bar,foo,baz', 'bar,baz,foo', 'bar,food,baz') { > print "s=$s "; > > my ($match) = $s =~ /some reg expression or perl code here to match foo/; any { $_ eq 'foo' } split(/,/, $s) if you're allowed to use List::MoreUtils 'any' > > if ($match) { > print "match=$match\n"; > } else { > print "no match\n"; > } > } > > > Indy Singh > IndigoSTAR Software -- www.indigostar.com > _______________________________________________ > toronto-pm mailing list > toronto-pm at pm.org > http://mail.pm.org/mailman/listinfo/toronto-pm -- Mike Stok http://www.stok.ca/~mike/ The "`Stok' disclaimers" apply. -------------- next part -------------- An HTML attachment was scrubbed... URL: From arocker at Vex.Net Mon Apr 29 12:07:57 2013 From: arocker at Vex.Net (arocker at Vex.Net) Date: Mon, 29 Apr 2013 15:07:57 -0400 Subject: [tpm] [Fwd: Re: String matching at start or middle or end of list] Message-ID: <1e183eadd52266744a366b4e56b33902.squirrel@mail.vex.net> > > my ($match) = $s =~ /some reg expression or perl code here to match foo/; > Stuart's suggestion works: ........ my $want = "foo"; my ($match) = $s =~ /\b($want)\b/; ....... produces s=foo,bar,baz match=foo s=bar,foo,baz match=foo s=bar,baz,foo match=foo s=bar,food,baz no match