sub get_x {
my @x = qw( stuff );
return wantarray ? @x : \@x;
}
####
return wantarray ? @x : \@x;
##
##
return wantarray ? @x : $x[0];
##
##
my $dewdrop_description = get_droplet();
$dewdrop_description->{substance} = 'water';
$dewdrop_description->{molecular_array} = get_moles( 'water' );
$dewdrop_description->{temperature} = 37;
##
##
my $dewdrop_description = {
%{ get_droplet() },
substance => 'water',
molecular_array => get_moles( 'water' ),
temperature => 37,
};
##
##
return wantarray ? @moles : \@moles;
##
##
my ($scalar) = why();
##
##
sub get_or_set {
my $self = shift;
if ( ! @_ && ! defined wantarray ) {
die "accessor called in void context";
}
$self->{stuff} = shift @_ if @_;
return $self->{stuff};
}
##
##
my @x = (); # but I thought it was qw( foo ) !
get_or_set( @x ); # set value