captainmikee has asked for the wisdom of the Perl Monks concerning the following question:

Hello,

I am having a strange problem with Strawberry Perl and file paths. Here is a short script that exhibits the problem:

use strict; use warnings; use AnyDBM_File; use POSIX; my $table_path = shift; my %hash_AB; my $table_file = "$table_path\\tableAB.db"; die "$table_path not a directory\n" unless ( -d $table_path ); die "$table_file not found\n" unless ( -f "$table_file" ); tie( %hash_AB, 'AnyDBM_File', "$table_file", 1, 0 ) or die( "open failed for $table_file: $!\n" );

When running this in Strawberry Perl, I get the following output:

>perl dbmopentest.pl Y:\path\to\dbdir open failed for Y:\path\to\dbdir\tableAB.db: No such file or directory

... even though I would expect to get one of the previous errors if the path were bad. Yesterday I could have sworn that I got it working in Cygwin, but only when I specified an absolute path. Today I can't get it to work in Cygwin either. I need it to work in Strawberry Perl and not Cygwin because I am planning to distribute my project with Strawberry Perl.

If I change the direction of slashes, I can make this work on Linux with the same file path (it's on a network drive). But Windows doesn't like it. Is there anything I can do?

Thanks in advance for your help.

Replies are listed 'Best First'.
Re: AnyDBM on Strawberry Perl: file can't be found
by rpnoble419 (Pilgrim) on Dec 24, 2009 at 19:30 UTC

    have you tried the following:

    my $table_file = $table_path."\\tableAB.db";

    are you sure your getting a value for $table_path. If you get no error on a absolute path, then you might want to test for a null value in your $table_path....

Re: AnyDBM on Strawberry Perl: file can't be found
by Anonymous Monk on Dec 25, 2009 at 01:09 UTC
    Try print $^E as well
    or die( "open failed for $table_file: $!\n$^E\n" );