Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > I'm confused by reference to reference in my code

Reply
Thread Tools

I'm confused by reference to reference in my code

 
 
surf
Guest
Posts: n/a
 
      02-06-2006

In a package I have this, I then use DB_File to tie
%data to a file:


package persist;

%data;

....
<various code>
....

---------------------------------
In another file I have the following code section.
I get a reference to the hash in the persist
package, put a hash reference into it
but when I take it back out it's no longer
a reference. What could I have done wrong ?


$typ = ref($r_session);
print("T:$typ <BR>\n");
$rf = \%persist::data;
$rf->{$app_id} = $r_session;
$myref = $rf->{$app_id};

$typ2 = ref($myref);
$typ3 = ref($rf);

print("T2:$typ2 <BR> \n");
print("T3:$typ3 <BR> \n");



this code prints:

T:HASH
T2:
T3:HASH

 
Reply With Quote
 
 
 
 
xhoster@gmail.com
Guest
Posts: n/a
 
      02-07-2006
"surf" <> wrote:
> In a package I have this, I then use DB_File to tie
> %data to a file:
>
> package persist;
>
> %data;
>
> ...
> <various code>
> ...
>
> ---------------------------------
> In another file I have the following code section.
> I get a reference to the hash in the persist
> package, put a hash reference into it
> but when I take it back out it's no longer
> a reference. What could I have done wrong ?


You tried to store multi-level data into a DB_File, which inherently
cannot store multi-level data.

Xho

--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
 
Reply With Quote
 
 
 
 
Tad McClellan
Guest
Posts: n/a
 
      02-07-2006
surf <> wrote:
>
> In a package I have this, I then use DB_File to tie
> %data to a file:
>
>
> package persist;



Lowercase package names are, by convention, reserved for pragmas.

package Persist;


> %data;



You should always enable strict (and warnings) when developing Perl code.

use warnings;
use strict;
my %data;


> What could I have done wrong ?



Failed to check the Perl FAQ before posting to the Perl newsgroup:

perldoc -q persist

How do I keep persistent data across program calls?

perldoc -q copy

How do I print out or copy a recursive data structure?


--
Tad McClellan SGML consulting
Perl programming
Fort Worth, Texas
 
Reply With Quote
 
 
 
Reply

Thread Tools

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Confused on how to reference info stored in a JFrame jamestechinfo@yahoo.com Java 1 02-12-2008 11:09 PM
confused about null reference compile error Steve Richter ASP .Net 4 04-26-2005 05:30 PM
where is the source code....??? ...am I ever confused....!! David Java 3 12-18-2004 06:10 PM
Newbie: How to duplicate a webform (including code) - I'm confused. Dave Smithz ASP .Net 4 10-27-2004 06:49 PM
Generated Code Confused G. Dean Blake ASP .Net 3 06-13-2004 07:28 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57