in reply to Conditional statements for template

You are missing a dollar sign before the variable name.

You cannot use if in an expression, but you can use the Conditional Operator (aka the Ternary operator):

#!/usr/bin/perl use warnings; use strict; use Data::Dumper; my $group = 'g'; my $exe = 'e'; for my $s_version (qw(s8 s9)) { my $template = { global => { variables => { version => "${s_version}", ($s_version eq "s8") ? (base => "\${version}/$group" +) : ( exe => "\${exe_state}", base => "\${s_version/${exe} +/$group" ), variant => "10", dir => "\${root}", }, }, }; print Dumper $template; }

Update: code formatting.

لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ