in reply to Referencing a HoA

You want @$aref = @$tables{$table_name}; instead of
@$aref = $tables{$table_name};
As for why $aref = $tables{$table_name} doesn't work, it's because $aref is just a scalar value, so you're just changing the value of the lexical $aref, not @fields.

/s

Update: See replies -- I forgot the curlies around $tables{$table_name}.

Replies are listed 'Best First'.
Re: Re: Referencing a HoA
by edoc (Chaplain) on Jun 02, 2003 at 02:44 UTC

    or would that be @$aref = @{$tables{$table_name}}; ?

    cheers,

    J

Re: Re: Referencing a HoA
by Anonymous Monk on Jun 02, 2003 at 02:52 UTC
    That yields the following message:
    Global symbol "$tables" requires explicit package name at noname.pl li +ne 18. Execution of noname.pl aborted due to compilation errors.
    Though I thought it was the equivalent of what BrowserUk posted:
    @$aref = @{ $tables{$table_name} };
    which does work. I guess I need to study references more closely. :(