in reply to Global vars?

Just to propose a TMTOWTDI solution that nobody else suggested yet..

Variables passed to a subroutine are automatically aliased to the @_ array, so if you modify them, you modify the original variables passed in:

use strict; my $X = 1; my $Y = 2; my $Z = 3; print "before: X=$X, Y=$Y, Z=$Z\n"; modifyvars($X, $Y, $Z); print "after: X=$X, Y=$Y, Z=$Z\n"; sub modifyvars { $_[0] = 2; $_[1] = 3; $_[2] = 4; }
Though this isn't too easy to read. I would have to agree with Zaxo -- if your version of Perl is new enough, prototypes make this cleaner to look at.