In Re: Module Naming Dilemma, Anonymous Monk asked why I wasn't simply aliasing typeglobs together for some code I was working on. Ignoring the fact that I wanted to minimize that behavior, I was kind of stumped by the following code snippet:
#!/usr/local/bin/perl -lw use strict; package Foo; sub new { print "Expected class: $_[0]"; bless {} => shift } sub test { print "Actual class: ". ref shift } package main; *Bar:: = \*Foo::; Bar->new->test; Foo::new('Bar')->test;
Both times that test() is called, I would expect ref to return Bar but it instead returns Foo. Why is that?
I (once again) cannot find where this behavior is documented, even though I suspect it is. Frankly, this code does not do what I would expect it to to do.
Cheers,
Ovid
New address of my CGI Course.
In reply to Two argument bless sometimes ignores the class name? by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |