in reply to convert directory content to dbf

The builtin functions opendir, readdir and closedir might be useful, e.g.:
my $dirpath = 'x/y/z'; my $dh = opendir $dirpath or die $!; map ProcessFile( "$dirpath/$_" ), readdir $dh; closedir $dh; sub ProcessFile { my $SOURCEFILE = shift; ( -f $SOURCEFILE ) or return; # ordinary files only my $TARGETFILE = $SOURCEFILE . '.out'; my $REPORTFILE = $SOURCEFILE . '.rpt'; # ... insert OP code here }

-M

Free your mind

Replies are listed 'Best First'.
Re^2: convert directory content to dbf
by johngg (Canon) on Feb 08, 2007 at 19:05 UTC
    my $dh = opendir $dirpath or die $!;

    I think you have got this a bit wrong. opendir takes two arguments (directory handle and path) and returns true on success. Your code should probably have read

    opendir my $dh, $dirpath or die $!;

    Cheers,

    JohnGG

Re^2: convert directory content to dbf
by oblate kramrdc (Acolyte) on Feb 08, 2007 at 16:56 UTC
    I used this but i get this error message always
    Not enough arguments for opendir at seccon.pl line 22, near "$dirpath + or" Execution of seccon.pl aborted due to compilation errors.
      That's because the code you were given is wrong. opendir takes two arguments, not one, and returns true if successful. It may help you to look at the opendir documentation. The code should read something like

      opendir my $dirHandle, $dirpath or die qq{opendir: $dirpath: $!\n};

      I hope this correction helps you make progress.

      Cheers,

      JohnGG