Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: working with directories

by zork42 (Monk)
on Sep 13, 2013 at 04:49 UTC ( #1053836=note: print w/ replies, xml ) Need Help??


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 }


Comment on Re: working with directories
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1053836]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (7)
As of 2014-08-22 23:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (168 votes), past polls