[EMAIL PROTECTED] wrote:
> Hello, this is my first post to activeperl. I'm getting familiar with Perl,
> but two things puzzle me and perhaps someone has the answers:
>
> 1) How would you add to a hash, similar to how you can "push" onto the end
> of an array? This is useful when reading through a list and adding to an
> array, but I can't find anything about doing it with a hash.

Just assign it:
	$hash{name} = $value;
unless the hash key is an array and you really want to push the value onto the array:
	push @{$hash{name}}, $value;

> 2) I prefer to use "use strict", which means all variables have to be
> preceded by "my," but what do you do when you need a "my" variable to be
> global so that another block of code can use it?

Place it at the top outside of any blocks in the file or use 'our $var;'
(later versions of Perl) or 'use vars qw($var);'

--
  ,-/-  __      _  _         $Bill Luebkert   ICQ=162126130
 (_/   /  )    // //       DBE Collectibles   Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      http://dbecoll.tripod.com/ (Free site for Perl)
-/-' /___/_<_</_</_     Castle of Medieval Myth & Magic http://www.todbe.com/


_______________________________________________
ActivePerl mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to