This is a bug report for perl from tassilo....@post.rwth-aachen.de,
generated with the help of perlbug 1.34 running under perl v5.8.2.
-----------------------------------------------------------------
[Please enter your report here]
I wonder whether this is a known issue:
ethan@ethan:~$ perl5.8.2 -Mif -e 'print if->VERSION'
syntax error at -e line 1, next token ???
Execution of -e aborted due to compilation errors.
It looks as though a package should never be identical to a Perl keyword
or otherwise you can't easily call class-methods of this package.
Tassilo
[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
category=library
severity=low
---
Site configuration information for perl v5.8.2:
Configured by root at Fri Nov 14 07:29:04 UTC 2003.
Summary of my perl5 (revision 5.0 version 8 subversion 2) configuration:
Platform:
osname=linux, osvers=2.4.21, archname=i686-linux
uname='linux ethan 2.4.21 #3 tue nov 11 09:22:00 utc 2003 i686 unknown '
config_args=''
hint=recommended, useposix=true, d_sigaction=define
usethreads=undef use5005threads=undef 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-strict-aliasing -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
optimize='-O3 -march=athlon -fomit-frame-pointer -foptimize-sibling-calls -finline-functions -fstrength-reduce -frerun-loop-opt -fexpensive-optimizations -fprefetch-loop-arrays -fmove-all-movables',
cppflags='-fno-strict-aliasing'
ccversion='', gccversion='3.2', gccosandvers=''
intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
alignbytes=4, prototype=define
Linker and Libraries:
ld='cc', ldflags =' -L/usr/local/lib'
libpth=/usr/local/lib /lib /usr/lib
libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
libc=/lib/libc-2.2.5.so, so=so, useshrplib=false, libperl=libperl.a
gnulibc_version='2.2.5'
Dynamic Linking:
dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
cccdlflags='-fpic', lddlflags='-shared -L/usr/local/lib'
Locally applied patches:
---
@INC for perl v5.8.2:
/usr/opt/perl5.8.2/lib/5.8.2/i686-linux
/usr/opt/perl5.8.2/lib/5.8.2
/usr/opt/perl5.8.2/lib/site_perl/5.8.2/i686-linux
/usr/opt/perl5.8.2/lib/site_perl/5.8.2
/usr/opt/perl5.8.2/lib/site_perl
.
---
Environment for perl v5.8.2:
HOME=/home/ethan
LANG=C
LANGUAGE (unset)
LC_CTYPE=de_DE@euro
LD_LIBRARY_PATH=:/usr/local/j2sdk1.4.0/jre/lib/i386:/usr/local/pwlib/lib:/usr/local/lib
LOGDIR (unset)
PATH=/usr/local/bin:/usr/bin:/bin:/usr/X11R6/bin:/usr/games:/usr/local/j2re1.4.1/bin:/usr/local/mpich-1.2.5/ch_p4/bin
PERLDOC_PAGER=/bin/less -isR
PERL_BADLANG (unset)
SHELL=/bin/bash
Indeed.
Related to this example:
$ perl5.8.2-unthreaded -e 'require if; if->import'
syntax error at -e line 1, near "if;"
Execution of -e aborted due to compilation errors.
Liz
Too late :)
Or, we could hack the lexer so the keywords "if" and "open", before
a ->, are always forced into a bareword.
I find it slightly annoying, but not difficult to circumvent:
% perl -Mif -e 'print "if"->VERSION'
0.03
When, exactly, does one *actually* need to call `if->VERSION',
anyway? :^/
- Kurt
Still, it's a bit fishy, even when quoting the bare word:
$ perl5.8.2-unthreaded -e 'use if'
$ perl5.8.2-unthreaded -e 'require if'
syntax error at -e line 1, at EOF
Execution of -e aborted due to compilation errors.
$ perl5.8.2-unthreaded -e 'require "if"'
Can't locate if in @INC (@INC contains:
/usr/local/lib/perl5/5.8.2/i686-linux /usr/local/lib/perl5/5.8.2
/usr/local/lib/perl5/site_perl/5.8.2/i686-linux
/usr/local/lib/perl5/site_perl/5.8.2
/usr/local/lib/perl5/site_perl/5.8.1/i686-linux
/usr/local/lib/perl5/site_perl/5.8.1 /usr/local/lib/perl5/site_perl
.) at -e line 1.
Liz
At 17:19 +0100 1/5/04, Elizabeth Mattijsen wrote:
> $ perl5.8.2-unthreaded -e 'require "if"'
> Can't locate if in @INC (@INC contains:
>/usr/local/lib/perl5/5.8.2/i686-linux /usr/local/lib/perl5/5.8.2
>/usr/local/lib/perl5/site_perl/5.8.2/i686-linux
>/usr/local/lib/perl5/site_perl/5.8.2
>/usr/local/lib/perl5/site_perl/5.8.1/i686-linux
>/usr/local/lib/perl5/site_perl/5.8.1 /usr/local/lib/perl5/site_perl
>.) at -e line 1.
$ perl5.8.2-unthreaded -e 'require "if.pm"'
(no errors)
Liz
> Tassilo v.Parseval (via RT) wrote:
> > I wonder whether this is a known issue:
> >
> > ethan@ethan:~$ perl5.8.2 -Mif -e 'print if->VERSION'
> > syntax error at -e line 1, next token ???
> > Execution of -e aborted due to compilation errors.
> >
> > It looks as though a package should never be identical to a Perl keyword
> > or otherwise you can't easily call class-methods of this package.
>
> Too late :)
>
> Or, we could hack the lexer so the keywords "if" and "open", before
> a ->, are always forced into a bareword.
Ick! I think the issue is not important enough to warrant yet another
special handling. For the future maybe it should be just recorded that
package name should be chosen a little more carefully.
The proper (albeit now impossible) solution would be to rename if.pm to
something less troublesome.
Tassilo
--
$_=q#",}])!JAPH!qq(tsuJ[{@"tnirp}3..0}_$;//::niam/s~=)]3[))_$-3(rellac(=_$({
pam{rekcahbus})(rekcah{lrePbus})(lreP{rehtonabus})!JAPH!qq(rehtona{tsuJbus#;
$_=reverse,s+(?<=sub).+q#q!'"qq.\t$&."'!#+sexisexiixesixeseg;y~\n~~dddd;eval
> I find it slightly annoying, but not difficult to circumvent:
>
> % perl -Mif -e 'print "if"->VERSION'
> 0.03
and this is another way:
$ perl -Mif -le 'print if::->VERSION'
0.03
--Gisle
And here is another, perhaps surprisingly:
$ perl -Mif -le "print main::if->VERSION"
0.04
/Autrijus/
Interesting then that this doesn't work (should it ?):
perl -Mif -le "print ::if->VERSION"
Can't call method "VERSION" without a package or object reference at -e line 1.
Or we go back and use Ilya's patch that allowed "use Foo if ^$O eq ...".
IIRC, he wrote if.pm because that patch was rejected.
May I point out that the open and sort pragmas are also affected by this
problem.
That would be much nicer, IMO. It does suffer from the same problem of
being backwards-incompatible though, so it would be something for 5.10.
One of the upcoming 5.8.x releases could then start a deprecation cycle.
Only partially, I think. 'sort' and 'open' aren't separatedly available
from the CPAN, 'if' is. At least for the VERSION case, I am pretty sure
there is less a need for calling '(sort|open)->VERSION'.
Maybe this glitch should just be documented in the manpages for sort,
open and if. Afterall, with using '(sort|...)::->method' an easy workaround
exists.
This isn't a problem restricted to keywords. If you have a sub Foo,
Foo->bar will be call the bar method on the result of &Foo(), not on
the Foo package. Foo::->bar should be used instead.
No but
nick@llama:/home/p4work/perl/maint-5.8> perl -Mif -le "print if::->VERSION"
0.03
nick@llama:/home/p4work/perl/maint-5.8>
should and does.
Fortunately, there's little reason to want to require if.pm.
--
Michael G Schwern sch...@pobox.com http://www.pobox.com/~schwern/
The plot seems complicated at first but with a little study it
becomes hopelessly confused.
- Peter Schickele, "Hansel and Gretel and Ted and Alice"