From: "John W. Krahn" <[EMAIL PROTECTED]>
> David Gilden wrote:
> >
> > How do get $i do increment inside the substitution below?
> >
> > #!/usr/bin/perl -w
> >
> > my $i = 0;
> >
> > while(<>)
> > {
> > chomp;
> > s/name=\"order/name=\"order$i++/;
> > print "$_\n";
> > }
>
> Another way to do it:
>
> s/name="order/name="order@{[$i++]}/;
>
> John
Hey you are right. Let's go crazy:
use Interpolation '=' => 'eval';
s/name="order/name="order$={$i++}/;
or even worse
use Interpolation 0.69 'incI:->$' => sub {$i++};
s/name="order/name="order$incI/;
The first creates a tied hash for which
$={$x} eq $x
for any $x. The second a tied scalar that increments $i each time you
read its value.
Jenda
===== [EMAIL PROTECTED] === http://Jenda.Krynicky.cz =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]