Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: Conditional statements for template

by graff (Chancellor)
on Mar 20, 2014 at 03:22 UTC ( #1079033=note: print w/ replies, xml ) Need Help??


in reply to Conditional statements for template

I don't understand what you're saying about templates, but just looking at your code snippet, it seems like a simple problem of assigning one thing or another to a part of hash structure, depending on some condition. That's not so hard - just move the conditional part outside the hash assignment:

my $template = { global => { variables => { version => "$s_version", variant => "10", dir => "$root", } } }; if ( $s_version eq "s8" ) { $template{global}{base} = "$version/$group"; } else { $template{global}{exe} => "$exe_state", $template{global}{base} => "$s_version/$exe/$group" , }
My example is different from your snippet in many little details - I was very confused by your use of back-slashes, dollar-signs and curly brackets inside of double-quotes, because it seemed strange and inconsistent. I simplified things, assuming that you probably have variables like "$group" and "$exe" defined somewhere else in your code, and you want those values used inside the quotes.

Your use of curly brackets outside of quotes was also pretty confused.

If you're not sure about the proper syntax to get what you want, please try to describe in better detail what you want, and maybe show us a bit more of your code, too. Or add just enough to the current snippet so that it should do something (like print something out).


Comment on Re: Conditional statements for template
Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (11)
As of 2014-07-31 15:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (249 votes), past polls