Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

[perl #24807] 'if->VERSION' not working as expected

0 views
Skip to first unread message

Tassilo V.Parseval

unread,
Jan 5, 2004, 3:18:29 AM1/5/04
to bugs-bi...@netlabs.develooper.com
# New Ticket Created by Tassilo v. Parseval
# Please include the string: [perl #24807]
# in the subject line of all future correspondence about this issue.
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=24807 >

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

Elizabeth Mattijsen

unread,
Jan 5, 2004, 10:54:55 AM1/5/04
to perl5-...@perl.org, bugs-bi...@netlabs.develooper.com
At 08:18 +0000 1/5/04, 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.

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

Rafael Garcia-Suarez

unread,
Jan 5, 2004, 10:59:24 AM1/5/04
to perl5-...@perl.org
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.

Kurt Starsinic

unread,
Jan 5, 2004, 11:08:45 AM1/5/04
to Elizabeth Mattijsen, perl5-...@perl.org, bugs-bi...@netlabs.develooper.com

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

Elizabeth Mattijsen

unread,
Jan 5, 2004, 11:19:16 AM1/5/04
to Kurt Starsinic, perl5-...@perl.org, bugs-bi...@netlabs.develooper.com

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

Elizabeth Mattijsen

unread,
Jan 5, 2004, 11:43:39 AM1/5/04
to Kurt Starsinic, perl5-...@perl.org, bugs-bi...@netlabs.develooper.com
Argh... caught by (lack of) magic bareword of require:

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 Von Parseval

unread,
Jan 5, 2004, 12:20:46 PM1/5/04
to Rafael Garcia-Suarez via RT
On Mon, Jan 05, 2004 at 04:05:18PM +0000 Rafael Garcia-Suarez via RT wrote:

> 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

Gisle Aas

unread,
Jan 5, 2004, 2:06:56 PM1/5/04
to Kurt Starsinic, Elizabeth Mattijsen, perl5-...@perl.org, bugs-bi...@netlabs.develooper.com
Kurt Starsinic <ks...@cpan.org> writes:

> 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

Autrijus Tang

unread,
Jan 5, 2004, 2:22:50 PM1/5/04
to Gisle Aas, Kurt Starsinic, Elizabeth Mattijsen, perl5-...@perl.org, bugs-bi...@netlabs.develooper.com
Gisle Aas wrote:
> and this is another way:
> $ perl -Mif -le 'print if::->VERSION'
> 0.03

And here is another, perhaps surprisingly:

$ perl -Mif -le "print main::if->VERSION"
0.04

/Autrijus/

Ton Hospel

unread,
Jan 5, 2004, 3:26:50 PM1/5/04
to perl5-...@perl.org
In article <3FF9B98A...@autrijus.org>,

Autrijus Tang <autr...@autrijus.org> writes:
> And here is another, perhaps surprisingly:
>
> $ perl -Mif -le "print main::if->VERSION"
> 0.04

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.

Yitzchak Scott-Thoennes

unread,
Jan 6, 2004, 3:40:21 AM1/6/04
to Tassilo von Parseval, Rafael Garcia-Suarez via RT
On Mon, Jan 05, 2004 at 06:20:46PM +0100, Tassilo von Parseval <tassilo....@post.rwth-aachen.de> wrote:
> On Mon, Jan 05, 2004 at 04:05:18PM +0000 Rafael Garcia-Suarez via RT wrote:
>
> > 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.

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.

Rafael Garcia-Suarez

unread,
Jan 6, 2004, 3:40:20 AM1/6/04
to perl5-...@perl.org

May I point out that the open and sort pragmas are also affected by this
problem.

Tassilo Von Parseval

unread,
Jan 6, 2004, 3:59:03 AM1/6/04
to Yitzchak Scott-Thoennes via RT

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.

Tassilo Von Parseval

unread,
Jan 6, 2004, 4:07:44 AM1/6/04
to Rafael Garcia-Suarez via RT
On Tue, Jan 06, 2004 at 08:46:04AM +0000 Rafael Garcia-Suarez via RT wrote:
> Yitzchak Scott-Thoennes wrote:
> >
> > On Mon, Jan 05, 2004 at 06:20:46PM +0100, Tassilo von Parseval <tassilo....@post.rwth-aachen.de> wrote:
> > > On Mon, Jan 05, 2004 at 04:05:18PM +0000 Rafael Garcia-Suarez via RT wrote:
> > >
> > > > 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.
> >
> > 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.

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.

Yitzchak Scott-Thoennes

unread,
Jan 6, 2004, 4:33:08 AM1/6/04
to Tassilo von Parseval, perl5-...@perl.org
On Tue, Jan 06, 2004 at 10:07:44AM +0100, Tassilo von Parseval <tassilo....@post.rwth-aachen.de> wrote:
>
> 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.

Nick Ing-Simmons

unread,
Jan 6, 2004, 6:56:38 AM1/6/04
to perl5-...@ton.iguana.be, perl5-...@perl.org

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.

Ton Hospel

unread,
Jan 6, 2004, 9:27:46 AM1/6/04
to perl5-...@perl.org
In article <2004010611...@llama.elixent.com>,
Then it's at least the first case I know where you can't drop the "main" in
a qualified package notation
$main::a => $::a
main::a() => ::a()
etc.

Michael G Schwern

unread,
Jan 14, 2004, 1:20:45 AM1/14/04
to Elizabeth Mattijsen, Kurt Starsinic, perl5-...@perl.org, bugs-bi...@netlabs.develooper.com
On Mon, Jan 05, 2004 at 05:19:16PM +0100, Elizabeth Mattijsen wrote:
> > When, exactly, does one *actually* need to call `if->VERSION',
> >anyway? :^/
>
> 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.

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"

0 new messages