×
Home About Us Products Services News Free Scripts Contact
news php scripts and software

Perl example - How do I loop through/list the files in a directory?


Perl - How do I loop through/list the files in a directory?

@files = </home/user/*>;
@all_files = </home/user/* /home/user/.*>;
@all_files = glob "/home/user/* /home/user/.*";

  opendir DIRH, "/home/user" or die "couldn't open: $!";
  foreach (sort readdir <DIRH>) 
  {
    print "one file in the directory is $_\n";
  }
  closedir DIRH;

Category: Perl

 
<< Go back