On Wednesday 05 May 2010, Shlomi Fish wrote:
> > 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.).
Thanks Shlomi for the explanation. I was amazed with some of the Perl tricks,
so wondering if it can go to that extent to blow me out completely.
--
Regards,
Akhthar Parvez K
http://Tips.SysAdminGUIDE.COM
UNIX is basically a simple operating system, but you have to be a genius to
understand the simplicity - Dennie Richie
--
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
http://learn.perl.org/