my $directory = "/path/to/files"; opendir DIR, $directory or die "can't open $directory: $!\n"; while (my $file = readdir DIR) { next unless -f "$directory/$file"; open FILE, "$directory/$file" or warn "Can't open $file: $!\n", next; # do stuff to FILE close FILE; } closedir DIR; #### perl -e 'print "How sweet does a rose smell? "; chomp $n = ; $rose = "smells sweet to degree $n"; *other_name = *rose; print "$other_name\n"'