use strict; use warnings; my %hash = ( "command1" => "type %s" ); my $var1 ="a.pl"; system(sprintf($hash{"command1"}, $var1));