#!perl use strict; use warnings; use Data::Dumper; for my $code (0 .. 1) { my $attached = $code ? { attach_path => 'etc' } : {}; my $args = { to => 'to email', from => 'from email', %$attached }; print Dumper($args); }