简体   繁体   English

如何从内存位置访问Perl对象?

[英]How do I access a Perl object from the memory location?

I want to access a Perl object in a script, which has been passed through Ajax. 我想在脚本中访问Perl对象,该脚本已通过Ajax传递。

I can't pass the object itself through JS Ajax, so I passed in the memory location for the object I want to access. 我无法通过JS Ajax传递对象本身,因此我传递了要访问的对象的内存位置。

Now in the Perl script I have a memory location, for example 现在在Perl脚本中,我有一个存储位置,例如

my $obj = "ClassName=HASH(0x9dccdb18)";

Now if I want to access the actual object for ClassName from this string of memory location, how can I do it? 现在,如果我想从此存储位置字符串访问ClassName的实际对象,该怎么办?

I want to be able to access the object and run the subroutines on that object. 我希望能够访问该对象并在该对象上运行子例程。

You can't. 你不能 Some of the reasons are spelled out in the comments. 评论中阐明了一些原因。 One additional reason is that even if you were to arrange to return the string to the same processes that generated it, there is no way you can be sure that the object still exists, or that if it does it still lives at the same memory location. 另一个原因是,即使您打算将字符串返回生成它的相同进程,也无法确保该对象仍然存在,或者如果确实存在,则它仍将位于相同的内存位置。 The only purpose of that string is to give the object a unique name. 该字符串的唯一目的是为对象赋予唯一名称。

You probably need to read perldoc Storable . 您可能需要阅读perldoc Storable You definitely need to ask about the actual problem you're trying to solve rather than something you think may be a solution to it. 您绝对需要询问您要解决的实际问题,而不是您认为可以解决的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM