#1
  1. No Profile Picture
    Registered User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2013
    Posts
    1
    Rep Power
    0

    Reading file name in specifc dir


    using the below code to read the files names in a specified dir.. some how its not working... any help plz

    @filelist = <C:\PID_Script\*>;
    foreach $filename (@filelist) {
    print $filename . "\n";
    }
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Novice (500 - 999 posts)

    Join Date
    Jun 2012
    Posts
    828
    Rep Power
    496
    Take a look at the opendir and readdir functions.

    Or use the glob function, which is even easier. Something like this:

    Perl Code:
    my @filelist = glob "C:\PID_Script\*.pl";
  4. #3
  5. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    May 2013
    Location
    /dev/null
    Posts
    163
    Rep Power
    19
    Originally Posted by Laurent_R
    Or use the glob function, which is even easier. Something like this:

    Perl Code:
    my @filelist = glob "C:\PID_Script\*.pl";
    The problem is not with using glob or <>; in fact both mean the same.

    The problem is with the path separator. Use "C:\\PID_Script\\*.pl" or "C:/PID_Script/*.pl"

IMN logo majestic logo threadwatch logo seochat tools logo