"cloning" tied hashes 
Author Message
 "cloning" tied hashes

I have implemented a TIEHASH class the details of which may or may not be
important.  I am tie'ing %sgmlrecs1 in such a way that it interfaces an
8000+ record file.  I am tie'ing %sgmlrecs2 (using the same class) in such
a way that it creates a new file.

Using the first block of code, from 2 to 6 of the 8000+ keys generate
calls to the STORE method in which the third parameter (the value) is
undefined.  The second block of code does not do this.  Is there a
known problem doing block 1) with two tied hashes?

1) %sgmlrecs2 = %sgmlrecs1;

2) while( my( $key, $val ) = each %sgmlrecs1 ) {
     $sgmlrecs2{ $key } = $val;
   }

Thanks,

-Brad



Mon, 30 Jul 2001 03:00:00 GMT  
 "cloning" tied hashes
: I have implemented a TIEHASH class the details of which may or may not be
: important.  I am tie'ing %sgmlrecs1 in such a way that it interfaces an
: 8000+ record file.  I am tie'ing %sgmlrecs2 (using the same class) in such
: a way that it creates a new file.

: Using the first block of code, from 2 to 6 of the 8000+ keys generate
: calls to the STORE method in which the third parameter (the value) is
: undefined.  The second block of code does not do this.  Is there a
: known problem doing block 1) with two tied hashes?

: 1) %sgmlrecs2 = %sgmlrecs1;

: 2) while( my( $key, $val ) = each %sgmlrecs1 ) {
:      $sgmlrecs2{ $key } = $val;
:    }

Not that I know of, if your class is implemented correctly.  Without
looking at the code, I can't tell, but make sure that you aren't using
package globals where you should be using instance variables.



Tue, 31 Jul 2001 03:00:00 GMT  
 "cloning" tied hashes

Quote:


> : 1) %sgmlrecs2 = %sgmlrecs1;
> : 2) while( my( $key, $val ) = each %sgmlrecs1 ) {
> :      $sgmlrecs2{ $key } = $val;
> :    }
> Not that I know of, if your class is implemented correctly.  Without
> looking at the code, I can't tell, but make sure that you aren't using
> package globals where you should be using instance variables.

Very interesting.  I was indeed using a package global that I see now
should have been in the object instead.  I have made that change, and am
still seeing the undefined values (2 consistently out of the 8125
records).  I may or may not take the time to investigate further.  It
occurred to me that I *really* don't want to do
'%sgmlrecs2 = %sgmlrecs1;', because unless I'm mistaken, perl flattens
those 8125 records into a list first.  Right?

Thanks for the reply--I'm glad I asked,

-Brad



Tue, 31 Jul 2001 03:00:00 GMT  
 "cloning" tied hashes
[A complimentary Cc of this posting was sent to Brad Baxter


Quote:
> > : 1) %sgmlrecs2 = %sgmlrecs1;
> Very interesting.  I was indeed using a package global that I see now
> should have been in the object instead.  I have made that change, and am
> still seeing the undefined values (2 consistently out of the 8125
> records).  I may or may not take the time to investigate further.

Looks like 5.004.  Right?  A lot of things were fixed since then.

Ilya



Tue, 31 Jul 2001 03:00:00 GMT  
 "cloning" tied hashes

Quote:
> Looks like 5.004.  Right?  A lot of things were fixed since then.

5.004, correct.  We're working on that upgrade, honest!
(That's not the "royal 'we'", but the "pass the buck 'we'".)

Regards,

-Brad



Tue, 31 Jul 2001 03:00:00 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. bug with "tie()"?

2. File integrity while using "tie"

3. "Tie" and memory usage

4. Perl5 "tie" problems

5. verifying write to file using "tie"

6. perl5 problem with dbmopen/tie and $var{"string"}++

7. "character class ""bug""

8. system(("cp", "-Rf", "/tmp/a/*", "/tmp/b")); doesnt wrk

9. how to parse a "this", "that", "and the ", "other" file

10. "can't declare hash elem.."

11. use of "delete" for hash keys

12. "fuzzy" hash matching or combinations

 

 
Powered by phpBB® Forum Software