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)
A better way of writing this (copied from your Re^2: working with directories post)
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 ($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 }
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 }
|
---|
In Section
Seekers of Perl Wisdom