Closed p5pRT closed 21 years ago
I have tested this under both Perl 5.005_03 on Windows and Linux and also on a June version of bleadperl. The exact same code fails in eval but works in Perl. OTOH in a much more complex example (not shown) it works just fine in eval().
bash-2.01$ perl $str = \<\<FOO; # line 1 "foo" sub bar { die('gotcha'); } &bar(); FOO
print "When executed by eval:\n"; eval($str); print $@;
print "When executed by perl:\n"; open (PERL\, "| perl") or die "Cannot start perl: $!"; print PERL $str; close PERL; __END__ When executed by eval: gotcha at (eval 1) line 3. When executed by perl: gotcha at foo line 2.
On Tue\, Aug 08\, 2000 at 11:04:46PM -0400\, Ben Tilly wrote:
I have tested this under both Perl 5.005_03 on Windows and Linux and also on a June version of bleadperl. The exact same code fails in eval but works in Perl. OTOH in a much more complex example (not shown) it works just fine in eval().
bash-2.01$ perl $str = \<\<FOO; # line 1 "foo" sub bar { die('gotcha'); } &bar(); FOO
print "When executed by eval:\n"; eval($str); print $@;
This is a known bug. The #line directive doesn't work on the first line of an eval. Just insert another line before it.
Ronald
Ben Tilly \ben\_tilly@​hotmail\.com writes:
This is a bug report for perl from ben_tilly@hotmail.com generated with the help of perlbug 1.26 running under perl 5.00503.
----------------------------------------------------------------- [Please enter your report here]
I have tested this under both Perl 5.005_03 on Windows and Linux and also on a June version of bleadperl. The exact same code fails in eval but works in Perl. OTOH in a much more complex example (not shown) it works just fine in eval().
#line as the very first few chars of an eval are not treated as a directive\, but just as a comment. You need a \n#line to make it work.
bash-2.01$ perl $str = \<\<FOO; # line 1 "foo" sub bar { die('gotcha'); } &bar(); FOO
print "When executed by eval:\n"; eval($str); print $@;
print "When executed by perl:\n"; open (PERL\, "| perl") or die "Cannot start perl: $!"; print PERL $str; close PERL; __END__ When executed by eval: gotcha at (eval 1) line 3. When executed by perl: gotcha at foo line 2.
[Please do not change anything below this line] -----------------------------------------------------------------
--- Site configuration information for perl 5.00503:
Configured by tilly at Fri May 28 18:22:31 EDT 1999.
Summary of my perl5 (5.0 patchlevel 5 subversion 3) configuration: Platform: osname=linux\, osvers=2.0.34\, archname=i386-linux uname='linux mcrubs1305 2.0.34 #1 tue aug 25 19:28:36 edt 1998 i586 unknown ' hint=recommended\, useposix=true\, d_sigaction=define usethreads=undef useperlio=undef d_sfio=undef Compiler: cc='gcc'\, optimize='-O2'\, gccversion=2.7.2.3 cppflags='-Dbool=char -DHAS_BOOL -I/usr/local/include' ccflags ='-Dbool=char -DHAS_BOOL -I/usr/local/include' stdchar='char'\, d_stdstdio=define\, usevfork=false intsize=4\, longsize=4\, ptrsize=4\, doublesize=8 d_longlong=define\, longlongsize=8\, d_longdbl=define\, longdblsize=12 alignbytes=4\, usemymalloc=n\, prototype=define Linker and Libraries: ld='gcc'\, ldflags =' -L/usr/local/lib' libpth=/usr/local/lib /lib /usr/lib libs=-lnsl -lndbm -ldb -ldl -lm -lc -lposix -lcrypt libc=\, so=so\, useshrplib=false\, libperl=libperl.a 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 5.00503: /usr/local/lib/perl5/5.00503/i386-linux /usr/local/lib/perl5/5.00503 /usr/local/lib/perl5/site_perl/5.005/i386-linux /usr/local/lib/perl5/site_perl/5.005 . --- Environment for perl 5.00503: HOME=/home/tilly LANG (unset) LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/usr/local/bin:/usr/bin:/bin:/usr/bin/X11:/usr/games:.:. PERL_BADLANG (unset) SHELL=/bin/bash
________________________________________________________________________ Get Your Private\, Free E-mail from MSN Hotmail at http://www.hotmail.com
"Ben Tilly" \ben\_tilly@​hotmail\.com wrote
I have tested this under both Perl 5.005_03 on Windows and Linux and also on a June version of bleadperl.
Heh! If you're playing with bleadperl\, you need to keep on the ball. This bug was mended about a month ago. :-)
A #line on the *first* line of an eval"" wasn't honoured. But now it is.
Mike Guy
On Wed\, 09 Aug 2000 21:36:50 -0000\, Nick Ing-Simmons wrote:
Ben Tilly \ben\_tilly@​hotmail\.com writes:
I have tested this under both Perl 5.005_03 on Windows and Linux and also on a June version of bleadperl. The exact same code fails in eval but works in Perl. OTOH in a much more complex example (not shown) it works just fine in eval().
#line as the very first few chars of an eval are not treated as a directive\, but just as a comment. You need a \n#line to make it work.
Dunno about the original problem\, but the eval "#line ..." bug has been fixed for 5.6.1 (chnage#5999).
Sarathy gsar@ActiveState.com
Migrated from rt.perl.org#3660 (status was 'resolved')
Searchable as RT3660$