Created
October 25, 2011 17:25
-
-
Save koorchik/1313571 to your computer and use it in GitHub Desktop.
Приватные методы в Perl с корректным отображением стека вызовов
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
# Private accessors/methods with correct "caller" | |
use Sub::Name; | |
# Помещаем ссылку на локальную анонимную функцию в локальную переменную | |
# и присваиваем ей имя "name" | |
my $name = subname "name" => sub { | |
my $self = shift; | |
... | |
} | |
# Используем как обыкновенный метод, но доступен оно только внутри класса | |
$self->$name(); | |
$self->$name('viktor'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment