Skip to content

Instantly share code, notes, and snippets.

@akanehara
Created February 17, 2021 02:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save akanehara/db59029941514497947787f69d5cabbe to your computer and use it in GitHub Desktop.
Save akanehara/db59029941514497947787f69d5cabbe to your computer and use it in GitHub Desktop.
HTTP::Message などで使われているアクセッサ実装ヘルパー
sub foo { shift->_elem('_foo', @_); }
sub bar { shift->_elem('_bar', @_); }
sub _elem
{
my $self = shift;
my $elem = shift;
my $old = $self->{$elem};
$self->{$elem} = $_[0] if @_;
return $old;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment