in reply to Parameter passing
Variables passed to a subroutine are automatically aliased to the @_ array, so if you modify them, you modify the original variables passed in:
Though this isn't too easy to read. Using prototypes (mentioned above) is better.use strict; my ($X, $Y); modifyvars($X, $Y); print "after: X=$X, Y=$Y\n"; sub modifyvars { $_[0] = 'foo'; $_[1] = 'bar'; my $rc = 0; $rc = 1 if $_[0] ne 'x'; return 0; }
|
|---|