#!/usr/bin/perl -w use strict; use Benchmark; use Data::Dumper; my $scalar; my @list; my %funcs = ( nothing => \¬hing, _undef => \&_undef, empty => \&empty, zero => \&zero, ); foreach my $func (keys %funcs) { no strict 'refs'; my $scalar = &{$funcs{$func}}(); print STDERR "scalar context $func == ", Dumper($scalar), "\n"; my @list = &{$funcs{$func}}(); print STDERR "list context $func == ", Dumper(\@list), "\n"; } sub nothing { return ; } sub _undef { return undef; } sub empty { return (); } sub zero { return 0; }