Skip to content

Instantly share code, notes, and snippets.

@sycobuny
Last active December 17, 2015 07:08
Show Gist options
  • Save sycobuny/5569967 to your computer and use it in GitHub Desktop.
Save sycobuny/5569967 to your computer and use it in GitHub Desktop.
Kinda sad that this doesn't actually work :-(
#!/usr/bin/env perl
use v5.18;
use warnings;
no warnings qw(experimental::lexical_subs);
use feature qw(lexical_subs);
package MyObject {
sub new { bless({}, __PACKAGE__) }
sub print_hello { shift->print("Hello, World") }
my sub print {
my ($self, $str) = @_;
say $str;
}
}
my ($obj) = MyObject->new();
$obj->print_hello();
__END__
% perl lexical_subs_sad.pl
Can't locate object method "print" via package "MyObject" at lexical_subs_sad.pl line 12.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment