zbck7g
Last Updated: February 25, 2016
·
658
· jbalthis

Perl: Quick Shorthand to Read Directory Listing

Perl has various shortcuts in order to do routine tasks. A favorite of mine is the shorthand syntax to open a directory and read its contents.

Note: Only applies to current working directory.

The Code:


@files = <*>;

foreach $file (@files) {

    //do whatever

}