Perl | Accessing a Directory using File Globbing Last Updated : 30 Jun, 2019 Comments Improve Suggest changes Like Article Like Report In Perl, a directory is used to store values in the form of lists. A directory is quite similar to a file. Just like a file, the directory also allows performing several operations on it. These operations are used for the modification of an existing directory or creation of a new one. A directory can be very easily opened and processed using the built-in function glob. Glob: It returns a list of files that match the expression passed in the argument. This function can print all or the specific files whose extension has been passed to it. Syntax: @list = <*>; // Prints all files in current directory @list = glob("*.pl"); // Prints all files in current directory with extension .pl @list = glob('//GeeksforGeeks//Files//*); // Prints all files in the given path Here are some examples that illustrate accessing a directory using File Globbing. Examples: Accessing the current directory of the script: Perl #!/usr/bin/perl -w # Accessing files using glob function @files = glob('*'); # Returns list of all files foreach $file (@files) # Loop to run through all files { print $file . "\n"; # Print all files } Output: Opening a specified directory: Perl #!/usr/bin/perl -w # Prints only the filename excluding the path use File::Basename; # Returns list of all files @files = glob('C:/Users/GeeksForGeeks/Folder/*'); foreach $file (@files) # Loop to run through all files { print basename($file), "\n"; # Print all files } Output: Comment More infoAdvertise with us Next Article Perl | Accessing a Directory using File Globbing V vishodushaozae Follow Improve Article Tags : Perl Perl-files Similar Reads Read all Files in Directory using R To list all files in a directory in R programming language we use list.files(). This function produces a list containing the names of files in the named directory. It returns a character vector containing the names of the files in the specified directories. If no files are present in the directory, 2 min read List all files of certain type in a directory using Python In python, there are several built-in modules and methods for file handling. These functions are present in different modules such as os, glob, etc. This article helps you find out many of the functions in one place which gives you a brief knowledge about how to list all the files of a certain type 3 min read Perl | Finding Files and Directories For traversing a directory tree in Perl, there are several ways/methods. Traversing can be performed through function calls opendir and readdir which are a part of Perl programming language. Traversing files and directories in Perl can also be done through File::Find module which comes with the Perl 3 min read Perl | Opening and Reading a File A filehandle is an internal Perl structure that associates a physical file with a name. All filehandles have read/write access, so once filehandle is attached to a file reading/writing can be done. However, the mode in which file handle is opened is to be specified while associating a filehandle. Op 4 min read C# Program For Listing the Files in a Directory Given files, now our task is to list all these files in the directory using C#. So to do this task we use the following function and class: DirectoryInfo: It is a class that provides different types of methods for moving, creating, and enumerating through directories and their subdirectories. You ca 2 min read Like