Xavier Noria [XN], on Tuesday, May 24, 2005 at 22:12 (+0200) typed the
following:
XN my $i = 0;
XN my @bar = map $_-[1], # take second component
XNgrep $_-[0] eq 'e', # let 'e's pass
XNmap [$_, ++$i],# arrayref [char, index of char]
XN
On 5/24/05, Robert Citek wrote:
I found a variation of this in the Perl Nutshell book:
$ perl -le '
$foo=fee fie foe foo ;
while ($foo =~ m/e/g ) {
push @bar, pos $foo ;
}
print join(:, @bar); '
2:3:7:11
Is there an equivalent way to do the same using map instead of an
On 5/24/05, Robert Citek [EMAIL PROTECTED] wrote:
On May 24, 2005, at 3:14 PM, Jay Savage wrote:
One thing that springs to mind is:
perl -le '
$foo = fee fie foe foo;
map {$i++; push @bar, $i if $_ eq e} split //, $foo;
print join(:,@bar)'
I'm not sure if it gains
On 5/25/05, Jay Savage [EMAIL PROTECTED] wrote:
On 5/24/05, Robert Citek [EMAIL PROTECTED] wrote:
I like your idea. Unfortunately, the above works only in the special
case where the regular expression match is actually a single-
character, exact match.
Regards,
- Robert
It works
On May 25, Jay Savage said:
/e(?{push @bar, pos})/g;
should work, but seems to ignore the /g.
Because as you wrote it, the regex is in void context, which means it'll
only match once. Put it in list context:
() = /e(?{ push @bar, pos })/g;
But this looks weird to almost anyone. I'd
On 5/25/05, Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote:
On May 25, Jay Savage said:
/e(?{push @bar, pos})/g;
should work, but seems to ignore the /g.
Because as you wrote it, the regex is in void context, which means it'll
only match once. Put it in list context:
() = /e(?{
On 5/25/05, Jay Savage [EMAIL PROTECTED] wrote:
[snip]
/p(?:{push @bar, pos})attern(?!)/g
oops!
make that:
/p(?{push @bar, pos})attern(?!)/g
--
daggerquill [at] gmail [dot] com
http://www.engatiki.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional
On May 25, Jay Savage said:
On 5/25/05, Jeff 'japhy' Pinyan [EMAIL PROTECTED] wrote:
On May 25, Jay Savage said:
/e(?{push @bar, pos})/g;
should work, but seems to ignore the /g.
Because as you wrote it, the regex is in void context, which means it'll
only match once. Put it in list
I found a variation of this in the Perl Nutshell book:
$ perl -le '
$foo=fee fie foe foo ;
while ($foo =~ m/e/g ) {
push @bar, pos $foo ;
}
print join(:, @bar); '
2:3:7:11
Is there an equivalent way to do the same using map instead of an
explicit while loop? I'm guessing not, since
On May 24, 2005, at 19:22, Robert Citek wrote:
I found a variation of this in the Perl Nutshell book:
$ perl -le '
$foo=fee fie foe foo ;
while ($foo =~ m/e/g ) {
push @bar, pos $foo ;
}
print join(:, @bar); '
2:3:7:11
Is there an equivalent way to do the same using map instead of an
Am Dienstag, 24. Mai 2005 19.22 schrieb Robert Citek:
I found a variation of this in the Perl Nutshell book:
$ perl -le '
$foo=fee fie foe foo ;
while ($foo =~ m/e/g ) {
push @bar, pos $foo ;
}
print join(:, @bar); '
2:3:7:11
Is there an equivalent way to do the same using
11 matches
Mail list logo