... @a = qw| / /home/ /var/ /tmp/ /var/tmp/ |; # afaik ls doesn't care if there is a trailing slash for directories ... #### ... @a = ('','/home','/var','/tmp','/var/tmp'); @b = map { chomp(my @x = `ls $_/`);[@x]} @a; # $_ interpolates to `ls /` for @a[0] # do the same for the print statement