Solved

Problem with tie and GDBM

Posted on 1997-05-21
3
517 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
  • 2
3 Comments
 
LVL 2

Expert Comment

by:mkornell
Comment Utility
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
Comment Utility
Was that the answer?

--mark;
0
 

Author Comment

by:moan
Comment Utility
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

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
pattern matching in perl 2 100
Which version of C should I use when Perl is too slow? 13 165
stftime format 4 51
Perl modules on linux ec2 3 84
Many time we need to work with multiple files all together. If its windows system then we can use some GUI based editor to accomplish our task. But what if you are on putty or have only CLI(Command Line Interface) as an option to  edit your files. I…
Email validation in proper way is  very important validation required in any web pages. This code is self explainable except that Regular Expression which I used for pattern matching. I originally published as a thread on my website : http://www…
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…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now