in reply to Reading DIR content and printing it

I usually try to recursively read directory content. This script will print to STDOUT each subdirectory and files in each subdirectory of your chosen directory:
#!/usr/bin/perl use strict; use warnings; my $dir = '/usr/lib/perl5/5.8.8/CGI'; @ARGV = $dir unless @ARGV; use File::Find; find sub { print $File::Find::name, -d && $dir, "\n" }, @ARGV;
Note that neither opendir, readdir, nor File::Find will print the "contents" of the files, just the names thereof.