RE: Should be a simple substitution?

2004-12-08 Thread Bakken, Luke
And is this method any faster or more efficient than this? $var =~ s/\{([^}]+)\}/$v = $1; $v =~ s!,!|!g; qq!($v)!/ge; Why not find out yourself? C:\src\perltype rebench.plx use strict; use Benchmark qw/cmpthese/; sub luke { my $var = 'blargh{a,b,c}'; my $v; $var =~

RE: Should be a simple substitution?

2004-12-08 Thread Bakken, Luke
$var =~ s{([^}]+)}(?:@{[ ($a = $1) =~ y/,/|/ $a ]}); Does it not need the 'ge' at the end? I don't understand why you are creating an anonymous array with a single value, then dereferencing it... And what does the ?: do? I think the ?: must be extraneous: C:\src\perlperl

Re: Should be a simple substitution?

2004-12-08 Thread Dave Gray
I think the ?: must be extraneous: That construct lets the regex engine know that it doesn't need to worry about saving backreferences to the parenthesized group. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] http://learn.perl.org/

RE: Should be a simple substitution?

2004-12-08 Thread Bakken, Luke
I think the ?: must be extraneous: That construct lets the regex engine know that it doesn't need to worry about saving backreferences to the parenthesized group. It's on the right hand-side of the regex, however. Look at the output: C:\src\perlperl -pes{([^}]+)}(?:@{[ ($a = $1) =~ y/,/|/

Re: Should be a simple substitution?

2004-12-08 Thread Dave Gray
It's on the right hand-side of the regex, however. Look at the output: C:\src\perlperl -pes{([^}]+)}(?:@{[ ($a = $1) =~ y/,/|/ $a ]}) blargh{a,b,c}blargh blargh(?:a|b|c)blargh The OP didn't want the ?: in there So it is! I'm usually a fan of one-liners, but I think this is a great

Re: Should be a simple substitution?

2004-12-07 Thread John W. Krahn
Bryan R Harris wrote: I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah If it's not obvious

Re: Should be a simple substitution?

2004-12-07 Thread John W. Krahn
John W. Krahn wrote: Bryan R Harris wrote: I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah

Re: Should be a simple substitution?

2004-12-07 Thread Bryan R Harris
I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah If it's not obvious I'm

Should be a simple substitution?

2004-12-06 Thread Bryan R Harris
I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah If it's not obvious I'm trying to

RE: Should be a simple substitution?

2004-12-06 Thread Bob Showalter
Bryan R Harris wrote: I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah Well, you

Re: Should be a simple substitution?

2004-12-06 Thread Bryan R Harris
I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah Well, you can do

Re: Should be a simple substitution?

2004-12-06 Thread Dave Gray
I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah Anybody have a faster way to do this? __CODE__ #!/usr/bin/perl use strict; use warnings; sub uncommify { my ($glob) =

RE: Should be a simple substitution?

2004-12-06 Thread Bakken, Luke
I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah Well, you can do

Re: Should be a simple substitution?

2004-12-06 Thread Bryan R Harris
I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah Well, you can do

Re: Should be a simple substitution?

2004-12-06 Thread Chris Devers
On Mon, 6 Dec 2004, Bryan R Harris wrote: Can you do this: $var =~ s/\{([^}]*)\}/$v = $1; $v =~ s!,!|!g; qq!($v)!/ge; Holy cow, is that legal??!! It took me at least 30 seconds just to figure out that those commands were inside the s/// command. See the 'e' at the end of the s///

Re: Should be a simple substitution?

2004-12-06 Thread Chris Devers
On Mon, 6 Dec 2004, Chris Devers wrote: On Mon, 6 Dec 2004, Bryan R Harris wrote: Can you do this: $var =~ s/\{([^}]*)\}/$v = $1; $v =~ s!,!|!g; qq!($v)!/ge; Holy cow, is that legal??!! It took me at least 30 seconds just to figure out that those commands were inside the

Re: Should be a simple substitution?

2004-12-06 Thread John W. Krahn
Bryan R Harris wrote: I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah If it's not obvious

Re: Should be a simple substitution?

2004-12-06 Thread Bryan R Harris
I can usually figure out regexes, and this one seems simple, but it still eludes me-- I'm looking for a regex (or a couple of regexes) to do the following: blahblah{ab,abcd}blah -- blahblah(ab|abcd)blah blahblah{a,b,c}blah -- blahblah(a|b|c)blah If it's not obvious I'm