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
In reply to Re: Bless a string
by moritz
in thread Bless a string
by Sewi
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |