Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Files and Perl for Windows

Expand Messages
  • merlyn@stonehenge.com
    ... gordon my @databack; gordon my @directories; gordon my $datadir= /www/g/my/directory/ ; gordon opendir(D, $datadir ) or my_die( Error in subroutine
    Message 1 of 2 , Dec 1, 2003
      >>>>> "gordon" == gordon Stewart <gordonstewart5@...> writes:

      gordon> my @databack;
      gordon> my @directories;
      gordon> my $datadir="/www/g/my/directory/";
      gordon> opendir(D, "$datadir") or my_die("Error in subroutine backup: can't open
      gordon> $datadir", $!);
      gordon> push(@databack,readdir(D));closedir(D);
      gordon> foreach $line (@databack){
      gordon> if ($line !~ m/^\./){
      gordon> if (-d $line){

      This isn't testing what you might think it's testing. You're looking
      at the filename (no path component) and asking if it's a directory.
      That's going to look for a file in the *current* directory for the test.
      Not the directory from which you read the name.

      gordon> push (@directories,$line);
      gordon> }
      gordon> }
      gordon> }

      If you're gonna mess with names, use glob(), or understand how
      to prepend the pathname to the results of readdir.

      Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
      <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
      Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
      See PerlTraining.Stonehenge.com for onsite and open-enrollment Perl training!
    Your message has been successfully submitted and would be delivered to recipients shortly.