Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do &function -- unexpected behavior #3525

Closed
p5pRT opened this issue Mar 5, 2001 · 3 comments
Closed

do &function -- unexpected behavior #3525

p5pRT opened this issue Mar 5, 2001 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Mar 5, 2001

Migrated from rt.perl.org#5973 (status was 'resolved')

Searchable as RT5973$

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2001

From [email protected]

jeffp@​hut [1​:00am] ~ #102> perl -w
sub foo { print "ok\n"; 123 }
do &foo;
ok
Perl v123.0.0 required--this is only v5.6.0, stopped (did you mean
v123.0.0?) at - line 2.

I do NOT know what to make of that. It seems like Perl interprets the
return value of a 'do &foo' as something to send to 'use' for a version
number. But what do you make of​:

jeffp@​hut [1​:02am] ~ #105> perl -w
sub foo { print 1 }
do &foo;
Perl v49.0.679940 required--this is only v5.6.0, stopped at - line 2.
1

That is bizarre.

Perl Info

Flags:
    category=core
    severity=medium

Site configuration information for perl v5.6.0:

Configured by robsiemb at Wed Jun 28 15:35:19 EDT 2000.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=freebsd, osvers=2.2.8-release, archname=i386-freebsd
    uname='freebsd hut.crusoe.net 2.2.8-release freebsd 2.2.8-release #0: fri sep 3 10:23:22 edt 1999 [email protected]:usrsrcsyscompilehut i386 '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='gcc', optimize='-O', gccversion=2.7.2.1
    cppflags='-I/usr/local/include'
    ccflags ='-I/usr/local/include'
    stdchar='char', d_stdstdio=undef, usevfork=true
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    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, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='ld', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib
    libs=-lm -lc -lcrypt
    libc=/usr/lib/libc.so.3.1, so=so, useshrplib=false, libperl=libperl.a
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags=' '
    cccdlflags='-DPIC -fpic', lddlflags='-Bshareable  -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /usr/local/lib/perl5/5.6.0/i386-freebsd
    /usr/local/lib/perl5/5.6.0
    /usr/local/lib/perl5/site_perl/5.6.0/i386-freebsd
    /usr/local/lib/perl5/site_perl/5.6.0
    /usr/local/lib/perl5/site_perl/5.005/i386-freebsd
    /usr/local/lib/perl5/site_perl/5.005
    /usr/local/lib/perl5/site_perl
    .


Environment for perl v5.6.0:
    HOME=/home/jeffp
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/usr/local/bin:/usr/bin:/usr/ucb:/usr/sbin:/usr/openwin/bin:/bin:/crusoe/appl/bin:/usr/local/netscape:/usr/ccs/bin:.:/home/jeffp/utils:/home/jeffp/bin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/tcsh

@p5pRT
Copy link
Author

p5pRT commented Mar 5, 2001

From [Unknown Contact. See original ticket]

On Mar 6, jeffp@​hut.crusoe.net said​:

This is a bug report for perl from japhy@​pobox.com,
generated with the help of perlbug 1.28 running under perl v5.6.0.

-----------------------------------------------------------------
[Please enter your report here]

jeffp@​hut [1​:00am] ~ #102> perl -w
sub foo { print "ok\n"; 123 }
do &foo;
ok
Perl v123.0.0 required--this is only v5.6.0, stopped (did you mean
v123.0.0?) at - line 2.

I do NOT know what to make of that. It seems like Perl interprets the
return value of a 'do &foo' as something to send to 'use' for a version
number. But what do you make of​:

jeffp@​hut [1​:02am] ~ #105> perl -w
sub foo { print 1 }
do &foo;
Perl v49.0.679940 required--this is only v5.6.0, stopped at - line 2.
1

That is bizarre.

It also occurs with​:

  $foo = sub { print 123 };
  do $foo->(); # odd Perl version message
  do &$foo; # odd Perl version message

(YES, I know do() for functions is deprecated.)

This is related, at least in the parsing aspect, to the UNTOUCHED bug
involving​:

  do(q(foo));
  # vs.
  do q(foo) ;

The first works, and tries to execute 'foo'. The second fails, and tries
to call the function &q. The parser mis-interprets a q, qq, qx, qr, or qw
after a 'do'.

@p5pRT
Copy link
Author

p5pRT commented Mar 6, 2001

From @tamias

On Tue, Mar 06, 2001 at 01​:06​:10AM -0500, jeffp@​hut.crusoe.net wrote​:

jeffp@​hut [1​:00am] ~ #102> perl -w
sub foo { print "ok\n"; 123 }
do &foo;
ok
Perl v123.0.0 required--this is only v5.6.0, stopped (did you mean
v123.0.0?) at - line 2.

I do NOT know what to make of that. It seems like Perl interprets the
return value of a 'do &foo' as something to send to 'use' for a version
number.

FYI​:

% perl -e 'do 123'
Perl 123 required--this is only version 5.00503, stopped at -e line 1.

% cat tmp
print "Hello world!\n";
% perl -e 'do tmp'
Hello world!
% perl -e 'sub foo { "tmp" } do &foo'
Hello world!

do &foo is being interpreted as do EXPR, not as do SUBROUTINE, which has
been the case since 5.005_03 if not earlier.

Ronald

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant