[Kochi-pm] Access Memory Location using Perl
Varghese Chacko
vctheguru at gmail.com
Wed Aug 25 07:20:41 PDT 2010
Good that you got it working.
I am still NOT convinced about why do you need to keep the reference in db?
As long as you have it in as a hash key, its going to cost toomuch db
interaction. if you have $object->{ "TAB_REFS" }{ $hash } = $hash;,
$object->{ "TAB_REFS" }{ $hash } will contain all info from/of $hash. If
not mandatory,always avoid DB access for performance :)
Just a suggestion :)
--VC
Bharathiraja P wrote:
> Thanks.
>
> I found a workaround and it works.
>
> I'm storing the address in db and add that address as key to class
> object like
>
> $object->{ "TAB_REFS" }{ $hash } = $hash
>
> So, from the DB I can get the address for the inactive tabs and
> destroy it easily.
>
> 2010/8/25 Varghese Chacko <vctheguru at gmail.com
> <mailto:vctheguru at gmail.com>>
>
> Raja,
>
> Its similar to 'C' memory allocation. ie, the address of the
> pointer is valid ONLY when the variable is in the system memory. I
> dont think you can get same data by storing an address in the db
> and then retrieving the address, unless you are trying to access
> some standard ports which always exists and accessible. So its NOT
> advisable to store hash reference in the database and cant
> guarentee to return the expected data every time you read that
> memory. You can always assign $my_new_hash_ref = 'HASH(0x91498b8)'
> and de-refer it as my $my_new_hash = %$my_new_hash_ref;. But it
> may NOT return any value or may return undef or may return some
> garbage or random value or a de-reference error.
>
> Give a try and let us know. You may paste your code-snippet so
> that we will get a better view of what you are trying to do and we
> may be able to suggest something.
>
>
> regards
> VC
>
>
>
>
> Bharathiraja P wrote:
>> I'm not actually printing. I'm just storing that address in db
>> and I want to access the hash using the address
>>
>> On Wed, Aug 25, 2010 at 2:00 PM, Shibu P U <shibu.pu at gmail.com
>> <mailto:shibu.pu at gmail.com>> wrote:
>>
>> You have written as "I have a hash reference and if we print
>> the reference variable we will get an address.".
>> Above, you are printing a variable no?? I meant that variable.
>>
>> Regards
>> Shibu P U
>>
>>
>>
>> On Wed, Aug 25, 2010 at 1:39 PM, Bharathiraja P
>> <pbrthemaster at gmail.com <mailto:pbrthemaster at gmail.com>> wrote:
>>
>> I have only the address not the reference variable.
>>
>>
>> On Wed, Aug 25, 2010 at 12:50 PM, Shibu P U
>> <shibu.pu at gmail.com <mailto:shibu.pu at gmail.com>> wrote:
>>
>> If you have the reference variable, can't you
>> dereference it and use?
>> For example, if $hashref is a hash reference, you can
>> dereference it as my %hash = %$hashref;
>>
>> Regards
>> Shibu P U
>>
>>
>> 2010/8/25 Bharathiraja P <pbrthemaster at gmail.com
>> <mailto:pbrthemaster at gmail.com>>
>>
>> I have a hash reference and if we print the
>> reference variable we will get an address. I want
>> to access the hash using that address.
>>
>> For ex. if $hash is a hash reference. If we print
>> $hash we will get something like HASH(0x91498b8).
>> I want to access the hash using the address
>> HASH(0x91498b8).
>>
>> 2010/8/25 Varghese Chacko <vctheguru at gmail.com
>> <mailto:vctheguru at gmail.com>>
>>
>> How do you get the memory address without any
>> type info like Array/Hash or Scalar? Are you
>> trying to access ports?
>>
>> --VC
>>
>> Bharathiraja P wrote:
>>> Hi,
>>>
>>> Can you tell how can I map memory
>>> location to a variable. For ex. I have a
>>> memory address for a hash reference say
>>> 0x23413. Is it possible to access the hash
>>> using the memory address?
>>>
>>> --
>>> Bharathiraja
>>> ------------------------------------------------------------------------
>>>
>>> _______________________________________________
>>> Kochi-pm mailing list
>>> Kochi-pm at pm.org <mailto:Kochi-pm at pm.org>
>>> http://mail.pm.org/mailman/listinfo/kochi-pm
>>>
>>
>>
>> --
>> Regards
>> Varghese Chacko
>>
>>
>> =========================================================
>> Unless you can create the WHOLE universe in 5 days, then
>> perhaps giving "advice" to God, isn't such a good idea.
>>
>>
>>
>> _______________________________________________
>> Kochi-pm mailing list
>> Kochi-pm at pm.org <mailto:Kochi-pm at pm.org>
>> http://mail.pm.org/mailman/listinfo/kochi-pm
>>
>>
>>
>> _______________________________________________
>> Kochi-pm mailing list
>> Kochi-pm at pm.org <mailto:Kochi-pm at pm.org>
>> http://mail.pm.org/mailman/listinfo/kochi-pm
>>
>>
>>
>>
>>
>
>
> --
> Regards
> Varghese Chacko
>
>
> =========================================================
> Unless you can create the WHOLE universe in 5 days, then
> perhaps giving "advice" to God, isn't such a good idea.
>
>
>
> _______________________________________________
> Kochi-pm mailing list
> Kochi-pm at pm.org <mailto:Kochi-pm at pm.org>
> http://mail.pm.org/mailman/listinfo/kochi-pm
>
>
> ------------------------------------------------------------------------
>
> _______________________________________________
> Kochi-pm mailing list
> Kochi-pm at pm.org
> http://mail.pm.org/mailman/listinfo/kochi-pm
>
--
Regards
Varghese Chacko
=========================================================
Unless you can create the WHOLE universe in 5 days, then
perhaps giving "advice" to God, isn't such a good idea.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.pm.org/pipermail/kochi-pm/attachments/20100825/6d8ba538/attachment.html>
More information about the Kochi-pm
mailing list