Fri, 17 May 2024


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

By: Peter, NetArt Media
Sat, 25 July 2020

@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: Web Development
Share this post:



See All Scripts






Subscribe for our newsletter

Receive the latest blog posts direct in your mailbox