my $cmd = 'a_cmd'; my %options = ( -d => '/home/users', -s => '/bin/sh', -g => 100, ); $options{-c} = $realname if $realname; $options{-d} = $base_homedir if $base_homedir; my $cmd_str = join ' ', $cmd, map { "$_ $options{$_}" } keys %options; my $output = qx/$cmd_str/; #### my $cmd = 'a_cmd'; my @options = ( -d => '/home/users', -s => '/bin/sh', -g => 100, ); my $output = qx/$cmd @options/; #### my @options = ( -d => '/home/users', # you can add -s => '/bin/sh', # add inline -g => 100, # comments as well '-m', # boolean switch ); # instead of my %options = ( -d => '/home/users', # isn't it nice to be able -s => '/bin/sh', # to put comments for esoteric -g => 100, # external program swithces? -m => '', # boolean switch );