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

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 the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (4)
As of 2016-10-22 08:49 GMT
Find Nodes?
    Voting Booth?
    How many different varieties (color, size, etc) of socks do you have in your sock drawer?

    Results (294 votes). Check out past polls.