ch15.046_prob_ex15.8
来自「Perl Best Practices the source code」· 8 代码 · 共 41 行
8
41 行
################################################################################ Example 15.8 (NOT RECOMMENDED) from Chapter 15 of "Perl Best Practices" #### Copyright (c) O'Reilly & Associates, 2005. All Rights Reserved. #### See: http://www.oreilly.com/pub/a/oreilly/ask_tim/2001/codepolicy.html ################################################################################# Example 15-8. Another way to implement accessor methods# Standard modules...use strict;use warnings;use IO::Prompt;use Carp;use English qw( -no_match_vars );use Data::Alias;use Readonly;my %name_of;my %rank_of;my %serial_num_of;# Provide access to the name attribute...sub name :lvalue { my ($self) = @_; return $name_of{ident $self};} sub rank :lvalue { my ($self) = @_; return $rank_of{ident $self};} # Serial numbers are read-only, so not lvalue...sub serial_num { my ($self) = @_; return $serial_num_of{ident $self};}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?