http://qs1969.pair.com?node_id=11145037


in reply to Deferring variables

We need more details for a good answer, e.g. you didn't show us your set() routine.

From the example demonstrated I'd say use $par{margin} and set it to the users input, like -horizontal

another approach is to grep a list of parameters, and take the first positive

($actual) = grep { $par{$_} ne "a" } qw/margin-left margin-horizontal margin/

(that's actually better done with first from List::Util )

Cheers Rolf
(addicted to the Perl Programming Language :)
Wikisyntax for the Monastery

update

debugger-demo with perl -de0

DB<21> $par{"margin-left"} = "a" DB<22> ($actual) = grep { $par{$_} ne "a" } qw/margin-left margin-ho +rizontal margin/ DB<23> p $actual margin-horizontal

update

If you need to do it for different head-parameters like "padding" and so on, try

$chain{margin} = [qw/margin-left margin-horizontal margin/ ]; # etc ($actual{$head}) = grep { $par{$_} ne "a" } @{ $chain{$head} };

and let $head loop over "margin", "padding", a.s.o.