use warnings; use vars qw( $choicesystem $choicehours $option $manager $host %hours $hourkey $row ); $host = `hostname`; our %filesystem = ( 1 => { name => "/filesystema", host => { namehost1 => 1 }, }, 2 => { name => "/filesystemb", host => { namehost2=> 2 }, }, 3 => { name => "/filesystemc", host => { namehost3 => 3 }, }, ); %hours=(1=>"48",2=>"96"); #print Dumper(%filesystem); debug chomp($host); print "$host\n"; print "----------------Menu-----------------------------------------\n"; print "Please choose from the list of file systems\n"; print "-------------------------------------------------------------\n"; for $row (sort keys %filesystem){ my $system=$filesystem{$row}; print "$row\t $system->{ name }\n"; } print "Please enter number>"; chomp($choicesystem = ); my $system = $filesystem{ $choicesystem }; print "----------------Menu-----------------------------------------\n"; print "Please choose the number of hours\n"; print "-------------------------------------------------------------\n"; foreach $hourkey (keys %hours){ print "$hourkey\t $hours{$hourkey} \n" } print "Please enter number>"; chomp($choicehours = ); my $choicehours = $hours{$choicehours}; if ( not $system->{host}{$host}){ system "/usr/bin/ssh $system->{host}#this part doesn't work, only brings back reference"; print "/usr/bin/sudo /usr/sbin/tmpwatch -f $choicehours $system->{name}\n"; } else { print "/usr/bin/sudo /usr/sbin/tmpwatch -f $choicehours $system->{name}\n";}