#!C:\perl\bin\perl use strict; use warnings; my %typehash = ( 'tomcat' => '\d$\logs\tomcat', 'tomcatweb' => '\d$\logs\web', 'apache' => '\d$\logs\Apache' ); sub getLog { my ($a,$type)=@_; my $server=$a; my $dir = "\\\\$server".$typehash{$type}; print "\n $dir "; chomp(my $meh = `dir /b /O:D $dir`); print $meh; } &getLog("test.control.com",'tomcat');