Skip to content

Instantly share code, notes, and snippets.

@haarg
Created December 18, 2018 15:02
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 haarg/c3fe1a2e32990603b052964239ab4396 to your computer and use it in GitHub Desktop.
Save haarg/c3fe1a2e32990603b052964239ab4396 to your computer and use it in GitHub Desktop.
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