On Feb 20, 6:16 pm, (e-mail address removed) wrote:
So what you are implying is that Perl looks at the "address" of $,
to enable its magic.
Do not think it is a productive way to describe the situation.
The ACTUAL way things happen is that nobody ever reads $, . A certain
container is attached to a "scalar" slot of *, ; Perl internals read
THIS CONTAINER when print() happens. *foo = \BAR reassign the scalar
slot of *foo.
And why doesn't this behavior impacting the Exporter ?
It is not clear what are you asking. After
*foo = \$, ;
assignments to $foo would change the same container as assignments to
$, .
> perl -wle "*foo = \$, ; $foo = 12; print 1,2"
1122
Ilya
How do we explain what is going on in this scenario:
#!/usr/local/bin/perl
use strict; use warnings;
print "Before:...";
print "\$,=[$,]";
print "\\\$,=",\$,;
print qw(A B); #< -- AB
no strict 'refs';
*{"::,"} = \do{":"};
use strict 'refs';
print "After1:...";
print "\$,=[$,]";
print "\\\$,=",\$,;
print qw(A B); # <---- AB
$, = "+";
print "After2:...";
print "\$,=[$,]";
print "\\\$,=",\$,; #
print qw(A B); # <--- AB
__END__
Even when $, is reassigned as "+" the print is not taking it.
maybe coz container is still pointing to the do{":}" even now.
That means perl has stored the address of the "original" container of
$, and looks at that when print() is invoked. And that is
an undocumented feature.
[snip]
printf("perl v%vd OS %s\n",$^V, $^O);
$, = '_';
my $sep = '*';
*{"::,"} = \$sep;
print "ok", "[$,]\n";
#---------------------- Displays results shown below:
perl v5.8.9 OS linux
ok_[*]
########################################################################################################
My question is basically the following:
"print" when it spits out a list, separates the list elements by the
$, variable's value.
Now, in the print statement I have above, one of the list elements is
$, itself. When it prints
$, it picks '*' (that's coz $, has been aliased to $sep).
But the elements are separated by '_' which is the original value of
$,
Why does print not use the new aliased value of $, for separating the
list elements? Could it be the print has squirreled away
the value of $, at compile time, which it'll use at run time to
separate the elements?
#############################