On Feb 21, [EMAIL PROTECTED] said:
>Using the following code, I want to create a hash or individual lists. Of
>course, this code doesn't work....
>
>What do I need to change to correct my error?
push() requires an array. $foo{bar} is a scalar. @{ $foo{bar} } is an
array.
>push($printQueue{A}, 'This is the first line in A');
>push($printQueue{A}, 'This is the second line in A');
>push($printQueue{A}, 'This is the third line in A');
>push($printQueue{A}, 'This is the fourth line in A');
>push($printQueue{A}, 'This is the fifth line in A');
push @{ $printQueue{A} }, ...;
You could just declare your hash as
my %printQueue = (
A => [ 'first', 'second', ... ],
B => [ ... ],
C => [ ... ],
);
>foreach my $key ('A', 'B', 'C') {
> foreach my $text ($printQueue{$key}) {
> print("$text \n");
> }
>}
Then, to loop over the array references, use
foreach my $text (@{ $printQueue{$key} }) { ... }
--
Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/
RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
<stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
[ I'm looking for programming work. If you like my work, let me know. ]
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]