in reply to need a regular exdpression in perl
ok, my program looks as below
#!/usr/bin/perl use strict; use File::Find; use warnings; my @file=("hh","yy","zz","aa","bb","hh","yy","zz","aa","bb","hh","yy", +"zz","aa","bb"); my $i=0; $string=" hi hello @begintobe replace @end asas x x x x x zxzxax hi hello hi hellooo @beginthis has tobe replaced @end"; my $x=$file[$i]; while ($string =~ s/\@begin([\w\W]*?)\@end/$x/ge) { $i++; $x=$file[$i]; print $i."\n"; } print $string;
and i am getting output as below so far<\p>
##output hi hello hh asas x x x x x zxzxax hi hello hi hellooo hh
only the first element in the arrray is getting replaced in every match...
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: need a regular exdpression in perl
by Eily (Monsignor) on Nov 20, 2014 at 09:38 UTC |