Your code as posted:
open IN, "d1.txt" or die "No such file:$!\n"; open OUT, ">ABC.txt" or die; while ( <IN> ) { chomp $_; $a[ $l ] = $_; ++$l; } my @array = qw( doxorubicin is a potent anti-estrogen drug and tamoxif +en ); for ( $i = 0; $i < $l; ++$i ) { for $z ( @array ) { if ( $z =~ /\b\w^$a[$i]$\b/i ) { $z =~ s/$z/<span>$z<\/span>/; $i++; print "@array "; } } }
My script is fine,
I don't see how you can say that.
You are trying to use the string "(5r)-6-(4-{[2-(3-Iodobenzyl)-3-Oxocyclohex-1-En-1-Yl]Amino}Phenyl)-5-Methyl-4,5-Dihydropyridazin-3(2h)-One" as a regular expression to match against the contents of @array but the elements of @array are all smaller than that string so they will never match. The regular expression has to be able to fit inside the string.
You are using the regular expression /\b\w^$a[$i]$\b/i which says: Match a Word boundary followed by a single Word character followed by the beginning of the string followed by the contents of $a[$i] followed by the end of the string followed by a word boundary. You can't match anything BEFORE the beginning of the string or AFTER the end of the string, there is nothing there to match.
In reply to Re: Invalid range []
by jwkrahn
in thread Invalid range []
by Nandini21
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |