Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
Hello Monks,
I have a Perl script which prints all .pl files inside the current folder/directory, but this script wont print the .pl files inside the main folder (or the directory). I need to modify this script to do so. Can any Monks kindly help me on this.
Thanks in advance.
( I use windows, in the below code it just prints all .pl files which are present in the F: directory, but wont print .pl files which present in its children folders. I need thi modification.)
use strict; use warnings; use English; my $dir = 'F:'; foreach my $fp (glob("$dir/*.pl")) { printf "%s\n", $fp; open my $fh, "<", $fp or die "can't read open '$fp': $OS_ERROR"; while (<$fh>) { printf " %s", $_; } close $fh or die "can't read close '$fp': $OS_ERROR"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Read Perl files inside a directory and its subfolders
by Random_Walk (Prior) on May 03, 2013 at 12:40 UTC | |
|
Re: Read Perl files inside a directory and its subfolders
by RichardK (Parson) on May 03, 2013 at 13:38 UTC | |
|
Re: Read Perl files inside a directory and its subfolders
by hdb (Monsignor) on May 03, 2013 at 12:40 UTC | |
|
Re: Read Perl files inside a directory and its subfolders
by 2teez (Vicar) on May 03, 2013 at 16:00 UTC |