... @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