On Jul 9, Tito Perez said:

>What is a simple way to iterate through the filenames
>of a directory?

The opendir(), readdir(), and closedir() functions.

  my $path = "/home/jeffp/pub_html/tmp";

  opendir DIR, $path or die "can't readdir $path: $!";
  while (defined (my $file = readdir DIR)) {
    next if $file eq '.' or $file eq '..';  # skip . and ..
    my $full = "$path/$file";

    # ...
  }
  closedir DIR;

Please refer to 'perlfunc'.

  perldoc perlfunc
  perldoc -f readdir

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
I am Marillion, the wielder of Ringril, known as Hesinaur, the Winter-Sun.
Are you a Monk?  http://www.perlmonks.com/     http://forums.perlguru.com/
Perl Programmer at RiskMetrics Group, Inc.     http://www.riskmetrics.com/
Acacia Fraternity, Rensselaer Chapter.         Brother #734
**      Manning Publications, Co, is publishing my Perl Regex book      **

Reply via email to