use strict; use warnings; use my_sort_routines; package myprogram; my @data = ( 4, 2, 1, 3 ); my @sorted_proto = sort my_sort_routines::prototyped @data; my @sorted_qual = sort my_sort_routines::qualify_pkg @data; print @sorted_proto, "\n"; #1234 print @sorted_qual, "\n"; #1234 package my_sort_routines; sub prototyped ($$) { # Access the arguments directly by indexing @_ $_[0] <=> $_[1]; } sub qualify_pkg { # Qualify $a and $b with the name of the calling package # Symbolic refs require "no strict refs" here # Symbol::qualify could simplify this, but this illustrates # how to do it without an additional module my $pkg = caller; no strict 'refs'; ${"${pkg}::a"} <=> ${"${pkg}::b"}; }