Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

What happens with a tie? 1

Status
Not open for further replies.

uida1154

Programmer
Joined
Mar 1, 2004
Messages
163
Location
NL
Hello all,

I have 2 questions concerning ties.

I use Config::Inifiles and tie a hash to an ini-file.

Is the hash filled with the data from the file at the tie or at usage of the hash?

With discussion with others I get the idea that the data is filled at usage, which leads to my next question: If the variable is filled at the tie, does the hash keep the data or is it thrown away again?

It is important for me to reduce the file-access so thats why I wanna know...
 
It's against my own principles and I hate doing this but is there someone out there who can help me out...please?
 
Can't help but to bump
--Paul
 
Have you read perltie? It sounds pretty much like it depends on the implementation. Looking in the source for Config::IniFiles's ReadConfig method (which can be called explicitly, or is done when the object is instantiated [which is also done when it is tied]), I found this little bit that appears to answer your question:
Code:
  # Get the entire file into memory (let's hope it's small!)
  local $_;
  my @lines = split /\015\012?|\012|\025|\n/, join( '', <$fh>);
Looks like it slurps, so like many things in Perl, it throws memory at a problem to make it fast. Config files often aren't large, so it's a pretty safe assumption.

Your bump was patient, and tasteful. Sometimes posts get lost and we need to be reminded. Best of luck, and enjoy your stay at Tek-Tips.

________________________________________
Andrew - Perl Monkey
 
Thanks a lot!

This means I do not have to bother with my improvement steps anymore (which would have make the code built up inconsequent).

And nice to know that I did not annoy anybody with my bump.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top