I've got this script:
#!/usr/bin/perl my $dirtoread="/home/mysite/public_html/t/d/"; opendir(IDIR, $dirtoread) || die "Error Opening Directory"; print "Content-type: text/html\n\n"; foreach $file ( sort readdir(IDIR) ) { ($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,$atime,$mtime,$ctime,$bl +ksize,$blocks) = stat($file); print <<EOF; File: $file dev: $dev ino: $ino mode: $mode nlink: $nlink uid: $uid gid: $gid rdev: $rdev size: $size atime: $atime mtime: $mtime ctime: $ctime blksize: $blksize blocks: $blocks } closedir(DIR);


Here is the output:
File: . dev: 771 ino: 5915501 mode: 16877 nlink: 2 uid: 32088 gid: 590 rdev: 0 size: 4096 atime: 1115011633 mtime: 1115011632 ctime: 1115011632 blksize: 4096 blocks: 8 File: .. dev: 771 ino: 1507821 mode: 16877 nlink: 5 uid: 32088 gid: 590 rdev: 0 size: 4096 atime: 1115009208 mtime: 1115009208 ctime: 1115009208 blksize: 4096 blocks: 8 File: files dev: ino: mode: nlink: uid: gid: rdev: size: atime: mtime: ctime: blksize: blocks: File: fileviewer.pl dev: 771 ino: 5915502 mode: 33261 nlink: 1 uid: 32088 gid: 590 rdev: 0 size: 616 atime: 1115011637 mtime: 1115011632 ctime: 1115011632 blksize: 4096 blocks: 8 File: index.html dev: ino: mode: nlink: uid: gid: rdev: size: atime: mtime: ctime: blksize: blocks:

The directory has a subdirectory called "files" and two files called "index.html" and "fileviewer.pl".

I see why nothing is coming back for "files" because it's a directory but why is "index.html" not coming back with any data?

I'm trying to list the Files and Directories in the current directory. For the Directories I'd like to know that it is a directory because I'm going to create a HTML link on it so people can browse around my server directory.

In reply to Why is Stat() Not Stating All Files? by awohld

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.