On Wednesday 05 May 2010 17:20:25 Akhthar Parvez K wrote: > On Wednesday 05 May 2010, Shlomi Fish wrote: > > 2. Don't use bareword filehandles - use lexical ones: > > > > open(my $output, ">>", $output) or die "Could not append to output - $!"; > > Wouldn't there be any issues if we use same name for lexical filehandle and > the scalar variable. Is Perl too intelligent to recognize both of them?
There certainly would be, and I don't think Perl is that intelligent to multiplex between the two uses of the same variable. I overlooked this double use of a variable with the same name ("$output"). So use $output_filename and $output_fh or something. If you want to see some Evil low-level hackery that causes one variable to masquerade as two in different contexts, see dualvar from Scalar::Util: http://perldoc.perl.org/Scalar/Util.html I think I've learned about it in the O'Reilly book "Perl Hacks" (which I can recommend). (Please don't use dualvar in production code - it's a very bad idea.). Regards, Shlomi Fish -- ----------------------------------------------------------------- Shlomi Fish http://www.shlomifish.org/ "Star Trek: We, the Living Dead" - http://shlom.in/st-wtld God considered inflicting XSLT as the tenth plague of Egypt, but then decided against it because he thought it would be too evil. 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/