develooper Front page | perl.perl5.porters | Postings from May 2007

[perl #43082] "$_[0]->method" interpolation

Thread Previous | Thread Next
From:
webmasters @ ctosonline . org
Date:
May 31, 2007 04:34
Subject:
[perl #43082] "$_[0]->method" interpolation
Message ID:
rt-3.6.HEAD-1668-1180574570-443.43082-75-0@perl.org
# New Ticket Created by  webmasters@ctosonline.org 
# Please include the string:  [perl #43082]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=43082 >


With "$_->method", $_ is interpolated, but '->method' is taken  
literally. However, if I put a subscript after the variable, I get a  
syntax error:

$ perl5.9.5 -le '$_[0] = "main"; print "$_[0]->method"'
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.

If I change "$_[0]->method" to "$_[0]\->method", it prints 'main- 
 >method', as I would expect the former to do as well. perlop says  
that methods calls such as "$obj->method" do not interpolate, but  
says nothing about "$_[0]->method" (with a subscript) being a syntax  
error.

Is this a bug? If not, could the error messages be changed in the  
following cases?

$ perl
{ "$_[0]->method"
}
^D
Unmatched right curly bracket at - line 2, within string
syntax error at - line 2, near "}"
Missing right curly or square bracket at - line 1, at end of line
Execution of - aborted due to compilation errors.

$ perl
"$_[0]->method'"
^D
String found where operator expected at - line 1, within string
         (Missing semicolon on previous line?)
Can't find string terminator "'" anywhere before EOF at - line 1.

$ perl -e'"$_[0]->method =~ /"'
Search pattern not terminated at -e line 1.

etc.


I hope this report helps.

Father Chrysostomos

---
Flags:
     category=core
     severity=low
---
Site configuration information for perl 5.9.5:

Configured by neo at Tue May 15 14:11:42 PDT 2007.

Summary of my perl5 (revision 5 version 9 subversion 5 patch 31224)  
configuration:
   Platform:
     osname=darwin, osvers=8.8.0, archname=darwin-2level
     uname='darwin treebeard.local 8.8.0 darwin kernel version 8.8.0:  
fri sep 8 17:18:57 pdt 2006; root:xnu-792.12.6.obj~1release_ppc power  
macintosh powerpc '
     config_args='-de -Dusedevel'
     hint=recommended, useposix=true, d_sigaction=define
     useithreads=undef, usemultiplicity=undef
     useperlio=define, d_sfio=undef, uselargefiles=define,  
usesocks=undef
     use64bitint=undef, use64bitall=undef, uselongdouble=undef
     usemymalloc=n, bincompat5005=undef
   Compiler:
     cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp - 
fno-strict-aliasing -pipe -I/usr/local/include',
     optimize='-O3',
     cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp- 
precomp -fno-strict-aliasing -pipe -I/usr/local/include'
     ccversion='', gccversion='4.0.0 20041026 (Apple Computer, Inc.  
build 4061)', gccosandvers='darwin8'
     intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
     d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
     ivtype='long', ivsize=4, nvtype='double', nvsize=8,  
Off_t='off_t', lseeksize=8
     alignbytes=8, prototype=define
   Linker and Libraries:
     ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/ 
local/lib'
     libpth=/usr/local/lib /usr/lib
     libs=-ldbm -ldl -lm -lc
     perllibs=-ldl -lm -lc
     libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,  
libperl=libperl.a
     gnulibc_version=''
   Dynamic Linking:
     dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
     cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/ 
usr/local/lib'

Locally applied patches:
     DEVEL

---
@INC for perl 5.9.5:
     /usr/local/lib/perl5/5.9.5/darwin-2level
     /usr/local/lib/perl5/5.9.5
     /usr/local/lib/perl5/site_perl/5.9.5/darwin-2level
     /usr/local/lib/perl5/site_perl/5.9.5
     /usr/local/lib/perl5/site_perl
     .

---
Environment for perl 5.9.5:
     DYLD_LIBRARY_PATH (unset)
     HOME=/Users/neo
     LANG (unset)
     LANGUAGE (unset)
     LD_LIBRARY_PATH (unset)
     LOGDIR (unset)
     PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/TeX/bin/powerpc- 
darwin6.8:/usr/local/bin
     PERL_BADLANG (unset)
     SHELL=/bin/bash


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About