M
MJS
How can the following pattern be matched and replaced by something
similar to it. After the pattern has been replaced, the replacing
pattern is repeating itself for certain number of times.
"The puzzle is :
go to your left=> continue
go to your right <= [ 20: 909]
continue[7:0] "
move.
This is how exactly how the text is written(including the spaces).
I can't figure out how to do it. Please help.
I tried something like this and didn't work:
===========================================================
# tie @array to filename using Tie::File
tie my @array, 'Tie::File', 'result.txt' or die "Cannot open
result.txt:$!";
while(<reading the text file>){
for($firstindex; $firstindex >= 0; $firstindex--){
$n++;
for ( 0 .. $#array ) {
my $string ="the above mentioned pattern"
if ( $array[ $_ ] =~ /string/ ) {
my $new_string= some similar pattern.
splice @array, $_ +1, 0, /the_string/;
last;
}
}
}
untie @array;
=============================================
similar to it. After the pattern has been replaced, the replacing
pattern is repeating itself for certain number of times.
"The puzzle is :
go to your left=> continue
go to your right <= [ 20: 909]
continue[7:0] "
move.
This is how exactly how the text is written(including the spaces).
I can't figure out how to do it. Please help.
I tried something like this and didn't work:
===========================================================
# tie @array to filename using Tie::File
tie my @array, 'Tie::File', 'result.txt' or die "Cannot open
result.txt:$!";
while(<reading the text file>){
for($firstindex; $firstindex >= 0; $firstindex--){
$n++;
for ( 0 .. $#array ) {
my $string ="the above mentioned pattern"
if ( $array[ $_ ] =~ /string/ ) {
my $new_string= some similar pattern.
splice @array, $_ +1, 0, /the_string/;
last;
}
}
}
untie @array;
=============================================