Hi,
I was wondering if someone could figure out why my pointer assignment below won't work!
In my code, I try to create a new hash %newhash at the same location as %hashy using the following code:
%newhash=%$var;
However, if you run the following code you will notice that \%hashy and \%newhash do not contain the same address values.
This is wrecking my head so any help would be much appreciated!
Thanks in advance!
Note: To run it, you'll need a file named, ph_nos, containing data like the following:
[CODE=perl]
#!usr/bin/perl/
open(FILEREAD," ph_nos");
@file_in=<FILER EAD>;
foreach $elem (@file_in)
{
@temp=split("," ,$elem);
%hashy = @temp;
$var = \%hashy;
print \%hashy;
}
%newhash=%$var;
print $var; #should be same val as below but it isn't?????
print \%newhash;[/CODE]
I was wondering if someone could figure out why my pointer assignment below won't work!
In my code, I try to create a new hash %newhash at the same location as %hashy using the following code:
%newhash=%$var;
However, if you run the following code you will notice that \%hashy and \%newhash do not contain the same address values.
This is wrecking my head so any help would be much appreciated!
Thanks in advance!
Note: To run it, you'll need a file named, ph_nos, containing data like the following:
Code:
sdfasd,sfads sdfasdf,sdfasd sdfasd,sdfads I.e. 2 strings seperated by commas.
#!usr/bin/perl/
open(FILEREAD," ph_nos");
@file_in=<FILER EAD>;
foreach $elem (@file_in)
{
@temp=split("," ,$elem);
%hashy = @temp;
$var = \%hashy;
print \%hashy;
}
%newhash=%$var;
print $var; #should be same val as below but it isn't?????
print \%newhash;[/CODE]
Comment