Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Deferring variables

by LanX (Sage)
on Jun 25, 2022 at 13:40 UTC ( #11145037=note: print w/replies, xml ) Need Help??


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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11145037]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2022-12-06 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?