Todd W wrote:
> 
> John W. Krahn wrote:
> > Paul wrote:
> >
> >>--- Julien Motch <[EMAIL PROTECTED]> wrote:
> >>
> >>>#The next line printsd the reference why ?
> >>>print("the host which you are connecteed to is $pop->Host()\n"); #
> >>>Mail::POP3Client=HASH(0x8153a8c)->Host()
> >>
> >>Inside the quotes, the -> operator is taken as printable characters.
> >
> > No, it is not.
> >
> > $ perl -le' $x->{one} = "HELLO"; print "Test $x->{one} test"'
> > Test HELLO test
> 
> Thats a hash lookup. The op tried to call a method in double quotes. I
> dont know exactly what happens, I'd say that since the interpreter saw
> that there was NOT a block "{ }" after the dereference operator it
> decided to take the "->" as prinable characters.

The problem is not with the -> operator, the problem is that only a
scalar or array will interpolate in a double quoted string.  Since
"->method()" in "$ref->method()" cannot be interpolated only the scalar
part is interpolated and the rest is just printed as is.

$ perl -le'$, = ", ";
$x = {zero => 1};
$y = [2];
$z = sub { 3 };
print  $x->{zero}, $y->[0], $z->();
print "$x->{zero}, $y->[0], $z->()";
print "$x->{zero}, $y->[0], @{[$z->()]}";
'
1, 2, 3
1, 2, CODE(0x8100398)->()
1, 2, 3



John
-- 
use Perl;
program
fulfillment

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

Reply via email to