Superbroom2.0 has asked for the wisdom of the Perl Monks concerning the following question:
I am trying to pretty much look for either ".xlsx" or ".pdf" file extensions within a directory, and if it finds them, do X, Y, and Z. This works if I just specify ".xlsx" but not the two or more together
while ($filename = readdir(DIR)) # read all entries +in directory { if (-f $filename) { if ($filename ne $SumRptName) # do NOT include th +e summary report file { $FileExt = ""; ($BaseFileName, $FileDir,$FileExt) = fileparse($filename +, qr/\.[^.]*/); print "$FileExt\n"; if ($FileExt eq ".xlsx") + # look for either .xlsx or .pdf || if ($FileExt eq ".pdf") { if (length($FileExt) > 3) { $FileExt = substr($FileExt, 1, 3); $OverrideExt = "/FileType=$FileExt "; } else { $OverrideExt = ""; } if ($FolderPerFile) # add BaseFile +Name to folder path { $Finalfld = $fld . $BaseFileName . "/"; } else { $Finalfld = $fld; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: How to look for two different file extensions?
by stevieb (Canon) on Mar 09, 2017 at 17:26 UTC | |
by Superbroom2.0 (Novice) on Mar 09, 2017 at 17:47 UTC | |
by haukex (Archbishop) on Mar 09, 2017 at 17:59 UTC | |
| |
by davies (Monsignor) on Mar 09, 2017 at 18:00 UTC | |
|
Re: How to look for two different file extensions?
by poj (Abbot) on Mar 09, 2017 at 18:57 UTC | |
|
Re: How to look for two different file extensions? glob them!
by Discipulus (Canon) on Mar 10, 2017 at 11:54 UTC | |
|
Re: How to look for two different file extensions?
by Anonymous Monk on Mar 09, 2017 at 18:14 UTC | |
|
Re: How to look for two different file extensions?
by Anonymous Monk on Mar 10, 2017 at 02:41 UTC |