Create an object at a given address: Difference between revisions

added Perl programming solution
(added Perl programming solution)
Line 578:
0 1 2 3 4 5 6 7
506097522914230528</pre>
 
=={{header|Perl}}==
The is basically a simplified version of the solution to the [https://rosettacode.org/wiki/Address_of_a_variable#Perl Address of a variable] task, so for more detail please consult that entry.
<lang perl># 20210218 Perl programming solution
 
use strict;
use warnings;
 
# create an integer object
 
print "Here is an integer : ", my $target = 42, "\n";
 
# print the machine address of the object
 
print "And its reference is : ", my $targetref = \$target, "\n";
 
# take the address of the object and create another integer object at this address
 
print "Now assigns a new value to it : ", $$targetref = 69, "\n";
 
# print the value of this object to verify that it is same as one of the origin
 
print "Then compare with the referent : ", $target, "\n"; </lang>
{{out}}
<pre>
Here is an integer : 42
And its reference is : SCALAR(0x1e25328)
Now assigns a new value to it : 69
Then compare with the referent : 69
</pre>
 
=={{header|Phix}}==
350

edits