LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 01-13-2005, 04:59 AM   #1
amnesty_puppy
Member
 
Registered: Aug 2004
Location: Britain
Distribution: Gentoo
Posts: 52

Rep: Reputation: 15
Perl: hash tying


I'm doing a Perl project for my computing A level (UK) and I'm using hash ties to access a database. When using multiple ties it seems that all the hashes are tied to the same object, where early in the program I have a tie to one hash with a certain contents I later tie a different hash and it has all the old keys and values as well, ones that haven't been overwritten. How can I make it create a new hash each time I want a tie?

Thanks, Dom.
 
Old 01-17-2005, 11:03 PM   #2
chrism01
Guru
 
Registered: Aug 2004
Location: Sydney
Distribution: Centos 6.5, Centos 5.10
Posts: 16,251

Rep: Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026Reputation: 2026
You can either:
1. tie each new hash to a new file
2. Clear and re-use same file over again like this:
tie(%hash, "DB_File", $filename);
%hash = ();
untie %hash;
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Perl and Hash automatic PB0711 Programming 3 09-23-2005 02:14 AM
Generating hash in perl ? MikeFoo1 Programming 3 05-21-2005 06:03 PM
Hash-sort like in PERL in C++ nyk Programming 4 06-11-2004 08:40 AM
Perl XML::Simple - Hash Question smaida Programming 2 05-26-2004 04:20 AM
renaming ENV hash in Perl nbp Programming 4 11-01-2003 03:07 AM


All times are GMT -5. The time now is 10:12 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration