pichels has asked for the wisdom of the Perl Monks concerning the following question:
#!perl -w # "-w" turns on all sorts of warnings about probable + errors. $dir = "r:\\\\40K\\"; sub listdirectory { local($dir); local(@lines); local($subdir); local($lvl_counter); local($list_length); $dir = $_[0]; if(opendir (DIR, $dir)) { @lines = readdir (DIR); closedir (DIR); $lvl_counter = 2; $list_length = ( scalar @lines ); while ($lvl_counter < $list_length) { $subdir = $dir."\\".$lines[$lvl_counter]; if(opendir (SUBDIR, $subdir)) { closedir (SUBDIR); &listdirectory($subdir); } else { print "$subdir\n"; } $lvl_counter++; } } } &listdirectory($dir);
OUTPUT:
read_import_test.pl r:\\40K\\A400332S1_05.pdf r:\\40K\\A400332S2_05.pdf r:\\40K\\A400332S3_05.pdf r:\\40K\\A400396S1_07.pdf r:\\40K\\A400396S2_07.pdf
How Can I remove the PATH and get just the basename?
How can I get just *.pdf, if this directory had different files in it? (like *.tif files)
I tried using File::Spec::Win32 and CWD but had problems?
Can someone tell me when I "should" download mods and use them.
And when I can just use scripts without modules?
Please let me know if you need more details and if you can help.
TIA!
Scott
20050207 Janitored by Corion: Added formatting
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Creating a script to pass dir name, basename and just *.pdf & *.tif files
by Zaxo (Archbishop) on Feb 07, 2005 at 16:25 UTC | |
by pichels (Initiate) on Feb 07, 2005 at 17:41 UTC | |
by Zaxo (Archbishop) on Feb 07, 2005 at 18:28 UTC | |
by pichels (Initiate) on Feb 07, 2005 at 19:39 UTC | |
|
Re: Creating a script to pass dir name, basename and just *.pdf & *.tif files
by brian_d_foy (Abbot) on Feb 07, 2005 at 16:05 UTC | |
|
Re: Creating a script to pass dir name, basename and just *.pdf & *.tif files
by holli (Abbot) on Feb 07, 2005 at 16:08 UTC | |
|
Re: Creating a script to pass dir name, basename and just *.pdf & *.tif files
by friedo (Prior) on Feb 07, 2005 at 16:06 UTC |