Hi
I have been reading the camel book; it's really fantastic
(and funny), but I still didn't understand some topics.
One thing that's not so clear is about constants made with
typeglobs and references; that's in page 295 of 3rd Ed.
I have made the following program to test them:

#!/usr/bin/perl -w
use strict;

our $PI;

$PI = \3.1415926535;
print "(1) $PI\n";
# prints SCALAR(0x8101f64)

$PI = 7;
print "(2) $PI\n";
# prints 7

*PI = \4.31415926;
print "(3) $PI\n";
# prints 4.31415926

$PI = \5.31419526;
# error: Modification of a read-only value attempted at ./m2 line 18.
print "(4) $PI\n";

And now the questions:

Question 1) Ignoring the different constant values,
Is the first and the third attributions equivalent?
It seems that not, but then, why? 
I thought that when I wrote
*PI = \value
I was giving the scalar $PI the value "reference to a value",
and not the value itself (that is what's being printed)!?

Question 2) Why cannot we make the 4th attribution? What is
making the scalar $PI a read-only? It cannot be the 
previous reference, because we also set it to a reference on the
first attribution, but we could change it on the second...

Thanks in advance and for a long time
Silvio Santana

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to