I believe my title may be a bit confusing, but here is the gist of what I am trying to do. I know this isn't "the right way" to do this, I'm more just curious if it is possible.
So lets say I have the script:
#!/usr/bin/perl
use strict;
use warnings;
my $foo = "bar";
my $foo_location = int(\$foo);
print $foo_location;
The output of this will be something like, 136167064
How can I take that integer (the location of $foo in memory), and create another variable which is a reference to $foo, using that integer.
So what I'd want to do is something like:
my $foo_reference = some_magical_function_call($foo_location);
Which would allow modifying the dereference of $foo_reference, to modify the value of $foo. So after whatever magic allows this to work,
$$foo_reference eq $foo
Would evaluate to true
I want to say that I figured this out a couple of years ago, but maybe I'm crazy.