From 96aa5ba171be75dbd25c44de813e74eb4e3d08b5 Mon Sep 17 00:00:00 2001 From: Jared Johnson Date: Fri, 20 Feb 2009 21:22:28 +0800 Subject: Shorten/clarify Connection and Transaction notes() Update Qpsmtpd::Connection::notes() and Qpsmtpd::Transaction::notes() with clearer, more brief syntax. A previous patch used seemingly better syntax, but did not evaluate the size of @_ in order to distinguish between a call to notes('arg1',undef) and notes('arg1'). This corrects this issue, and adds a comment to that effect. --- lib/Qpsmtpd/Connection.pm | 8 ++++---- lib/Qpsmtpd/Transaction.pm | 9 ++++----- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/lib/Qpsmtpd/Connection.pm b/lib/Qpsmtpd/Connection.pm index 22ed704..99b7b38 100644 --- a/lib/Qpsmtpd/Connection.pm +++ b/lib/Qpsmtpd/Connection.pm @@ -108,10 +108,10 @@ sub hello_host { } sub notes { - my $self = shift; - my $key = shift; - @_ and $self->{_notes}->{$key} = shift; - $self->{_notes}->{$key}; + my ($self,$key) = (shift,shift); + # Check for any additional arguments passed by the caller -- including undef + return $self->{_notes}->{$key} unless @_; + return $self->{_notes}->{$key} = shift; } sub reset { diff --git a/lib/Qpsmtpd/Transaction.pm b/lib/Qpsmtpd/Transaction.pm index 18635ad..1dec547 100644 --- a/lib/Qpsmtpd/Transaction.pm +++ b/lib/Qpsmtpd/Transaction.pm @@ -61,11 +61,10 @@ sub header { #} sub notes { - my $self = shift; - my $key = shift; - @_ and $self->{_notes}->{$key} = shift; - #warn Data::Dumper->Dump([\$self->{_notes}], [qw(notes)]); - $self->{_notes}->{$key}; + my ($self,$key) = (shift,shift); + # Check for any additional arguments passed by the caller -- including undef + return $self->{_notes}->{$key} unless @_; + return $self->{_notes}->{$key} = shift; } sub set_body_start { -- 1.7.2.2