$class is the same as $x (i.e. the bigint 27) the whole way through new, and bless implicitly stringifies its second argument (like print implicitly stringifies its arguments).
ref($x)->new(48) should do what you want. Another reasonably common idiom is:
my $new = (ref($existing) // $existing)->new(...)
This allows $existing to be either an existing object or a class name.
In reply to Re^3: Math::BigInt new
by tobyink
in thread Math::BigInt new
by QM
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |