Created
March 12, 2010 13:59
-
-
Save kamipo/330317 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
package string; | |
use overload '""' => sub { ${$_[0]} }; | |
sub __ : method : lvalue { substr(${$_[0]}, $_[1], $_[2]) } | |
package main; | |
use Data::Dump qw/dump/; | |
sub p { print dump(@_), "\n" } | |
sub _ { local $_ = $_[0]; bless \$_, 'string' } | |
p "practice 1"; | |
$se = _"google"; | |
p $se_ar = [$se, $se]; | |
$se = _"yahoo"; | |
p $se_ar; | |
p "practice 2"; | |
$se = _"google"; | |
p $se_ar = [$se, $se]; | |
(__$se(0, 6)) = _"yahoo"; | |
p $se_ar; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment