Bootstrap FreeKB - Perl (Scripting) - Store files directories in array (glob)
Perl (Scripting) - Store files directories in array (glob)

Updated:   |  Perl (Scripting) articles

The glob operator can be used to get a list of files in a directory. For example, let's say you have a Linux system with the following files.



glob can be used to store each file in an array. The nice thing about glob is that it can easily handle the wildcard character.

my @files = glob("/usr/local/file*.txt");


Likewise, glob works if you have a Windows system. This makes glob quite appealing, as this would make your Perl scripts compatible across platforms.

my @files = glob("C:\users\john\Documents\file*.txt");


Did you find this article helpful?

If so, consider buying me a coffee over at Buy Me A Coffee


Add a Comment

Please enter cd99bb in the box below so that we can be sure you are a human.