Reference of table of hask

hi,

I have a table of hash

my [at] Tab = (
{ cour => '001', heure => '10:20', date =>
'01/01/2006' },
{ cour => '002', heure => '10:20', date =>
'01/01/2006' },
);


and for add elements I want to push new emements in a SUB function. like
this :
addElement(\ [at] Tab);

sub addElement {
my ?????? = shift;
}

How can I declare this variable ?

Thank

Lactarius.
Lactarius [ So, 08 Januar 2006 00:23 ] [ ID #1131938 ]

Re: Reference of table of hask

Lactarius wrote:
> I have a table of hash
>
> my [at] Tab = (
> { cour => '001', heure => '10:20', date =>
> '01/01/2006' },
> { cour => '002', heure => '10:20', date =>
> '01/01/2006' },
> );

More commonly named "array of hashes".

> and for add elements I want to push new emements in a SUB function. like
> this :
> addElement(\ [at] Tab);
>
> sub addElement {
> my ?????? = shift;
> }

First you need something to add. Let's assume you have:

my $element = {
cour => '003',
heure => '10:20',
date => '01/01/2006',
};

Then you can do:

addElement( \ [at] Tab, $element );

sub addElement {
my ($tabref, $element) = [at] _;
push [at] $tabref, $element;
}

Suppose you'd better read up on references and data structures.
Suggested reading:

perldoc perlreftut
perldoc perlref
perldoc perldsc
perldoc perllol

Good luck!

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Hjalmarsson [ So, 08 Januar 2006 00:58 ] [ ID #1132740 ]
Perl » alt.perl » Reference of table of hask

Vorheriges Thema: net::rawip source code question
Nächstes Thema: open remote file without modules