Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 avoiding work at the Monastery: (14)
As of 2015-07-30 16:55 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (273 votes), past polls