Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine

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).

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1079033]
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (2)
As of 2018-05-27 16:24 GMT
Find Nodes?
    Voting Booth?