Hi Rajeev, On Tue, 16 Aug 2011 17:38:16 -0700 (PDT) Rajeev Prasad <rp.ne...@yahoo.com> wrote:
> > > foreach $str1 (@arr1){ > foreach (@arr2) { > @arr3 = split(/ /,"$_"); > print "array = @arr3 element0 = $arr3[0] element1 = $arr3[1]"; #this > is just to check, it showing values 0 and 1 as correctly assigned > print "$str1"; That's your mistake. Perl does not have double-interpolation (which may be considered a security vulnerability.). To overcome this in your case, you can use this: $str1 =~ s/\b\$arr3\[(\d+)\]\b/$arr3[$1]/ge; # Untested. If you're looking for something better, then look at the various options in: http://perl-begin.org/uses/text-generation/ A few comments on your code: 1. Use "strict" and "warnings". 2. Always do «foreach my $str1 (@arr1)» and limit the scope of the variables using "my". 3. Don't iterate using $_. It's very easy to devastate and pollute it. 4. Don't say «"$foo"» instead of «$foo», unless $foo is an object that needs to be stringified (which is probably not the case). 5. See http://perl-begin.org/tutorials/bad-elements/ for more advice. Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ Understand what Open Source is - http://shlom.in/oss-fs * Backward compatibility is your worst enemy. * Backward compatibility is your users’ best friend. Please reply to list if it's a mailing list post - http://shlom.in/reply . -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/