Hm, your code worked for me. It seems that, for some reason, your script is getting 1 as the pathname. So, there are three files in the same directory as the dirrecur script? What are the permissions on those? You might want to do an ls -l . from the prompt to confirm they are there. (I beleive you, but it's occam's razor - eliminate the simple things first) :) You might also try putting the following statement below your use statements:
use Carp;
and in the code, instead of die, use croak, like this (I added a carriage return at the end to make it more readable):
opendir (DIR, $path) or croak "Unable to open $path: $!\n";
That may give your more verbose information. I find it very useful in my code, as it gives a trace of the subroutine calls, values passed in, etc.

Update: here's the entire code, as it worked for me. I noticed that you had a typo in your die statement, too - it should be $!, not ! or 1.

#!/usr/bin/perl use strict; use warnings; use Carp; sub processFiles { my $path = shift; opendir (DIR, $path) or croak "Unable to open $path: $!"; my @files = readdir (DIR); closedir (DIR); foreach my $myfile (@files) { print "Files: $myfile\n"; } } print "$0 started at " . (localtime) . "\n"; processFiles(@ARGV); print "$0 finished at " . (localtime) . "\n";

-- Burvil


In reply to Re^3: No Filenames Returned by bowei_99
in thread No Filenames Returned by coolboarderguy

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.