13.07.2015 Views

Perl 语言编程 - Linux教程

Perl 语言编程 - Linux教程

Perl 语言编程 - Linux教程

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

package MagicDec;use overloadq(--) => \&decrement,q("") => sub { ${ $_[0] } };sub new {my $class = shift;my $value = shift;bless \$value => $class;}sub decrement {my @string = reverse split (//, ${ $_[0] } );my $i;for ( $i = 0; $i < @string; $i++ ) {last unless $string[$i] =~ /a/i;$string[$i] = chr( ord($string[$i]) + 25 );}$string[$i] = chr( ord($string[$i]) - 1);my $result = join(' ', reverse @string);$_[0] = bless \$result => ref($_[0]);}337

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!