# get $filename
if (-d $filename) {
# a dir
} elsif (-f $filename) {
# a normal file
} else {
# something else
}
from the frivolous to the serious | [reply] [d/l] [select] |
Most excellent. Thank you very much. I must say that this is a great site in my quest to learn Perl. Everyone is very helpful and quick to offer advice. Thank you.
Kalimeister
| [reply] |
Also note that on all platforms I'm aware of, directories can have extensions. And files are certainly not required to have extensions.
| [reply] |
I would also suggest (in case you are tempted to use a system command) that you use File::Copy for the copy operation. It's part of the standard Perl distribution.
Update: I noticed that I forgot to mention why you should use File::Copy. Besides being portable across multiple operating systems, it is also easier to use than the usual alternatives (such as using `cp` or creating your own routine to read a file and write it in another location).
Impossible Robot | [reply] |
You might also be interested in the slew of such operators that can make your life a lot easier.-X . | [reply] |