Tuesday, July 12, 2011

Globbing concept in perl

Perl supports globbing which helps you to find files with wildcard characters.
To print all the files starting with "f" in the current directory use the script below


Perl script:

@array=; # this can be modified to your need
print "@array\n";

OUTPUT:

G:\perl_programs>perl perl_globbing.pl
function_perl.pl function_sendarray.pl


This concept can be also used to delete all the backup files ending with .bak in the current directory using the following lines:


unlink(<*.bak>);

No comments:

Post a Comment