#!/usr/bin/perl use warnings; use strict; use feature qw{ say }; { package My::Url; sub new { my $class = shift; bless {@_}, $class } sub url { my ($self, $node_id) = @_; $self->{url} . '?node_id=' . $node_id } } my $o = 'My::Url'->new(url => 'http://www.perlmonks.org/'); my $methodname = 'url'; my $methodref = $o->can($methodname); say $o->$methodref(1142751);