hi all
i was going through some perl code i came across this line and i am not getting what is exactly going on ..
$$this{localtion} = GetName->GetVarName("EXE_DIR") ;
what is the red part doing in above code
hi all
i was going through some perl code i came across this line and i am not getting what is exactly going on ..
$$this{localtion} = GetName->GetVarName("EXE_DIR") ;
what is the red part doing in above code
From the hash 'this', get the value associated with the key 'localtion', and treat it as a reference to a scalar.
This is not really correct.
$this is a hash reference. That is, a reference to a hash. $$this{'location'} dereferences $this to access the value associated with the "location" key.
Another way to write this is $this->{'location'} = 'xxxxxxx';
You may easily confirm this by using Data::Dumper to inspect complex data structure.
C:\Users\bernardchan>perl -MData::Dumper -e "$$this{'location'}='xxxx'; print Dumper($this)"
$VAR1 = {
'location' => 'xxxx'
};
C:\Users\bernardchan>perl -MData::Dumper -e "$this->{'location'}='xxxx'; print Dumper($this)"
$VAR1 = {
'location' => 'xxxx'
};