use strict; use warnings; sub foo { wantarray() ? 10 : 1; } print "${\foo()}\n"; #outputs 10