Since the empty string is a valid blessed class
No, it's not. If the second argument of bless is the empty string, the thing being blessed is blessed into
main. If you turn on warnings, Perl will tell you so.
Otherwise, how would you distinguish the empty blessing from the unblessed, religious overtones notwithstanding?
That's easy.
blessed returns
main in the first case, and so does
ref.
ref returns the empty string if its argument isn't a reference - and that's never ambigious, and hence there would be any ambiguity if
blessed would do the same.
#!/usr/bin/perl
use strict;
use warnings;
use Scalar::Util 'blessed';
my $ref = bless [], "";
print ref $ref, "\n";
print blessed $ref, "\n";
__END__
Explicit blessing to '' (assuming package main) at "..." line 8.
main
main