in reply to Problem with an array in a package

Try something like:
# Page Layout - Legal, Landscape our %landscape_lgl = ( set_paper => [5], set_landscape => [], set_margins_LR => [.50], set_center => [], set_hide_gridlines => [], set_fit_to_pages => [] );
and
foreach my $statement (keys(%landscape_lgl)) { $worksheet->$statement(@{$landscape_lgl{$statement}}), print "$worksheet->$statement","\n"; }
This will not preserve the order of your statements in the %landscape_lgl hash. If you need to do that, have a separate array:
@landscape_lgl = qw/set_paper set_landscape.../
And use that in place of the keys() part.

Alternatively, keep your original loop, but instead of the $worksheet->$statement call in the foreach body, use

eval $statement; warn "something went wrong in $statement: $@" if $@;
All code untested.

Replies are listed 'Best First'.
Re: Re: Problem with an array in a package
by jcoxen (Deacon) on Jan 14, 2004 at 20:06 UTC
    Many thanks!!! eval $statement; did the trick.