http://www.perlmonks.org?node_id=1053836


in reply to working with directories

Are you aware of the file test operators?

A better way of writing this (copied from your Re^2: working with directories post)
print "Enter a directory´s path to work with all files in a folder or +a single file path\n\n"; chomp(my $input = <STDIN>); if ($input =~ /./){ ### attempt of recognizing a file extention ... process file }elsif ($input =~ /[^.]/){ #### attempt of recognizing just a folder +but i know it wont work always ... process folder }
Would be something like this:
print "Enter a directory´s path to work with all files in a folder or +a single file path\n\n"; chomp(my $input = <STDIN>); if (-f $input){ # $input is the name of an existing file ... process file }elsif (-d $input){ # $input is the name of an existing folder ... process folder }