in reply to Re: Execute error on opendir
in thread Execute error on opendir

stajich I added the line of code you provided, and it appears that $element is trying to use a relative path. Any suggestions on how to correct this?

Replies are listed 'Best First'.
Re: Re: Re: Execute error on opendir
by hmerrill (Friar) on Aug 14, 2002 at 14:38 UTC
    It's always safest(not sure if it's required) to give opendir an absolute directory name - that is, a directory name with a fully qualified path. Do the "element"s in /Scripts/rotlog have absolute directory names in them?

    And, the $name that readdir returns is *NOT* an absolute filename. Therefore, before you try to test $name with a -M filetest operator, you must provide the absolute path to $name - something like this:
    my $current_abs_dir = "/path/to/opendir/directory"; while ($name = readdir(REP)) { $abs_name = "$current_abs_dir/$name"; if (-M $abs_name >= 10) {
    If the elements in /Scripts/rotlog do not include the absolute path to the directory, you'll need to get the absolute path to the directory from somewhere.

    Read the perldocs for opendir and readdir by doing
    perldoc -f opendir perldoc -f readdir
    HTH.
      Thanks, and yes the lines in /Scripts/rotlog are absolute paths. I want to read the contents of the dir in each line (path) of the /Scripts/rotlog file into the array. The issue is using the array elements instead of hard coding the paths.
Re: Re: Re: Execute error on opendir
by waswas-fng (Curate) on Aug 14, 2002 at 14:15 UTC
    Add a $prepath = '/some/path/to/that/makes/elementfullyqual' right below the shabang, then rewrite the open and -d test with "$prepath$element"...

    -Waswas
      Thanks, but that made matters worse. The contents of the 'rotlog" file are fully qualified directory paths. Any other ideas?