in reply to Re: How to read files in a directory, directory path to be given through CMD
in thread How to read files in a directory, directory path to be given through CMD

Sorry, but have you run your code? I ran it and on entering path name after running my perl script it says :
C:\Perl64\bin>perl t1.pl C:\Perl64\bin Can't do inplace edit: C:\Perl64\bin is not a regular file at t1.pl li +ne 20.
  • Comment on Re^2: How to read files in a directory, directory path to be given through CMD
  • Download Code

Replies are listed 'Best First'.
Re^3: How to read files in a directory, directory path to be given through CMD
by kennethk (Abbot) on Jun 11, 2012 at 19:23 UTC
    Ahh, so you do not intend STDIN, but rather @ARGV for your input. In that case, you might use
    use strict; use warnings; foreach my $file (@ARGV) { if (-f $file) { print "This is a file: $file\n"; } if (-d $file) { print "\n\nThis is a directory: $file\n"; } }

    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Re^3: How to read files in a directory, directory path to be given through CMD
by BrowserUk (Patriarch) on Jun 11, 2012 at 20:10 UTC
    Can't do inplace edit: C:\Perl64\bin is not a regular file at t1.pl line 20.

    How can you possibly be getting a error on line 20 of kennethk's code, when neither version of the code he posted has 20 lines?


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.

    The start of some sanity?