Solved

Problem with tie and GDBM

Posted on 1997-05-21
3
540 Views
Last Modified: 2012-06-27
I need to use gdbm databases with Perl but get the error:

"Can't locate object method "TIEHASH" via package "GDBM_FILE" " at
my_first_db.pl line 5."


when using this code:


#! /bin/perl -w
use GDBM_File;
use POSIX;
use Fcntl;
tie(%db, "GDBM_FILE", "my_db", &GDBM_WRCREAT, 0644);


Is it a bug in Perl5.003, or is there a workaround?

I am using Perl5.003 with the gdbm-1.7.3 library statically linked, both
compiled with gcc-2.7.2.2 on a Sun ULTRA running Solaris2.5.
0
Comment
Question by:moan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 2

Expert Comment

by:mkornell
ID: 1204086
try:

tie(%db, GDBM_File, "my_db", &GDBM_WRCREAT, 0644);

i.e. change "GDBM_FILE" to "GDBM_File".  You also don't need the quotes.
       
0
 
LVL 2

Accepted Solution

by:
mkornell earned 50 total points
ID: 1204087
Was that the answer?

--mark;
0
 

Author Comment

by:moan
ID: 1204088
mkornell's answer solved my problem.
The code I tried was directly copied/pasted from an online manual
that had the syntax wrong!


0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I've just discovered very important differences between Windows an Unix formats in Perl,at least 5.xx.. MOST IMPORTANT: Use Unix file format while saving Your script. otherwise it will have ^M s or smth likely weird in the EOL, Then DO NOT use m…
On Microsoft Windows, if  when you click or type the name of a .pl file, you get an error "is not recognized as an internal or external command, operable program or batch file", then this means you do not have the .pl file extension associated with …
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

756 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question