sub get_data { ...; return; # undef in scalar context or the empty list in list context } #### sub get_data { ...; return undef; # undef in scalar context and a one-item list containing undef in list context } #### sub enable_warnings { my $self = shift; $self->{warnings} = 1; return $self; } sub enable_errors { my $self = shift; $self->{errors} = 1; return $self; } sub disable_warnings { my $self = shift; $self->{warnings} = 0; return $self; } sub disable_errors { my $self = shift; $self->{errors} = 0; return $self; } sub run_process { my $self = shift; ...; return $result; } # Now instead of doing this: $widget->enable_warnings; $widget->enable_errors; my $result = $widget->run_process; # We can do this: my $result = $widget->enable_warnings->enable_errors->run_process; #### sub bleh { return $result; } #### sub bleh { $result; }