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 =~
$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
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/
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/,/|/
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
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
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
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
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
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
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
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) =
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
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
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///
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
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
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
18 matches
Mail list logo