Solved

Problem with tie and GDBM

Posted on 1997-05-21
3
556 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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 …
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…
Six Sigma Control Plans

615 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