sub substrref { \substr($_[0], $_[1], $_[2]) } $x = substrref("blah", 1, 2); $y = substrref("florp", 1, 3); print "$$x $$y\n";