in reply to Bless a string
As the error message explains, you can only pass references to bless, so do that:
bless \$string;
(The second argument of bless defaults to __PACKAGE__, so no reason to repeat that).
Note that the blessing sticks to the string, not to the reference, so you can access the package information even if you only pass the string itself around:
$ perl -wE 'my $s = "foo"; bless \$s; say ref \$s' main
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Bless a string
by Sewi (Friar) on Dec 01, 2011 at 11:29 UTC | |
by moritz (Cardinal) on Dec 01, 2011 at 12:57 UTC | |
by Eliya (Vicar) on Dec 01, 2011 at 12:49 UTC |