On Mon, Feb 21, 2005 at 09:14:54AM -0600, Tim Wilson wrote:
> Hey everybody,
> 
> I'm a Perl newbie and I've having trouble with the following snippet of
> code. This code represents a part of what I'm trying to do to modify our
> district's Request Tracker system. (http://bestpractical.com/rt/)
> 
> I have this:
> 
> #!/usr/bin/perl
> 
> my %watchers;
> $watchers{"ESC"} = qw/A B C/;

You're assigning a list ("A", "B", "C") to a scalar $watchers{"ESC"} in that
line. In this case the scalar takes on the last value in the list: "C".

If you want $watchers{"ESC"} to be an array of values, try this instead

$watchers{"ESC"} = ["A", "B", "C"];

The square brackets turns the list into a reference to an anonymous array.

> $Building = "ESC";
> @emails = $watchers{$Building};

Here you'll want to convert your reference to an array back to a real array,
so maybe something like this:

@emails = @{$watchers{$Building}};

The @{} dereferences the contents as an array.

Array and hash references were the hardest thing for me to learn in perl.

-Steve