Hacker News new | ask | show | jobs
by draegtun 5458 days ago
Your example isn't exactly identical because its not making use the $self object. Your example would look more like this in Perl:

my $name = ref $args{form_name} eq 'CODE' ? $args{form_name}->(@user_options) : $args{form_name};

Taking the original Perl example I would probably write it like this:

my $name = do { my $c = $args{form_name}; ref $c eq 'CODE' ? $self->$c(@user_options) : $c };

Which seems DRYer to me.