jeff loetel <[EMAIL PROTECTED]> wrote: : Try this: : : #!/usr/bin/perl : : &GetMarmots; : : sub GetMarmots { : %result = (); : $result{'steppe marmot'} = 4; : $result{'himalayan marmot'} = 3; : $result{'mongolian marmot'} = 1; : $result{'woodchuck'} = 6; : return %result; : } : : foreach (keys %result) {print "$_\n";} : print "\n";
Er, no, don't try that. The example above uses a global variable (%result). Whenever possible, try to avoid globals. If you think you need globals, try looking at your problem from a different angle. When programs get long global variables are very difficult to track. A better approach is to use private variables and to seldom change passed parameters. my %result = GetMarmots(); sub GetMarmots { my %result = (); $result{'steppe marmot'} = 4; $result{'himalayan marmot'} = 3; $result{'mongolian marmot'} = 1; $result{woodchuck} = 6; return %result; } Also use "GetMarmots()" instead of "&GetMarmots" to call this sub. Read 'perlsub' for more info. &foo; is the same as: foo( @_ ); # and disable prototypes That may not always be what you want. HTH, Charles K. Clarkson -- Head Bottle Washer, Clarkson Energy Homes, Inc. Mobile Home Specialists 254 968-8328 -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]