Created
December 18, 2018 15:02
-
-
Save haarg/c3fe1a2e32990603b052964239ab4396 to your computer and use it in GitHub Desktop.
This file contains 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
use strict; | |
use warnings; | |
{ | |
package QROverload; | |
use overload 'qr' => sub { | |
my $self = shift; | |
qr/(??{ $self->_as_qr($_) })/; | |
}; | |
sub new { | |
my $class = shift; | |
my $self = bless {}, $class; | |
} | |
sub _as_qr { | |
my $self = shift; | |
warn "generating qr for: $_[0]"; | |
$_[0] = "garf"; | |
qr/./; | |
} | |
} | |
my $f = QROverload->new; | |
my $foo = "qwe"; | |
my $g = $foo =~ $f; | |
warn $foo; | |
warn $g; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment