in reply to Re: Is "ref($class) || $class" a bad thing?
in thread Is "ref($class) || $class" a bad thing?
I am not sure I understand your point. I think you are trying to say that
is no better/worse than$class = ref($class) || $class;
which is quite true, and since that is also a common idiom which will produce the same issue, then maybe that is not so good either.my $class = shift; bless {}, $class;
In all cases, $class is undef, and when bless is passed undef it blesses into main. It might (and I stress might, because I am not so sure of this) make sense if when bless encountered undef in its second argument, that it treated it as a one-argument bless instead (which would result in blessing into the current package).
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Is "ref($class) || $class" a bad thing?
by chromatic (Archbishop) on Jul 12, 2004 at 19:52 UTC | |
by stvn (Monsignor) on Jul 12, 2004 at 20:42 UTC | |
by chromatic (Archbishop) on Jul 12, 2004 at 21:20 UTC | |
by stvn (Monsignor) on Jul 12, 2004 at 22:29 UTC | |
by chromatic (Archbishop) on Jul 12, 2004 at 23:26 UTC | |
| |
|
Re^3: Is "ref($class) || $class" a bad thing?
by eric256 (Parson) on Jul 12, 2004 at 20:03 UTC | |
by dragonchild (Archbishop) on Jul 12, 2004 at 20:09 UTC |