Confusing behavior with 'use' and 'eval' 
Author Message
 Confusing behavior with 'use' and 'eval'

Hello,

I'm experiencing some odd behavior with 'use' and 'eval'. It's
probably best to just share some code:

----------------------------------------------------------------------
#!/usr/local/bin/perl5

package main;
&Bobo::do;

package Bobo;
use Socket;

sub do {
    eval { &do_impl(1, 2) };

    eval { &do_impl(); };

    eval { &do_impl(1, 2) };

Quote:
}

sub do_impl { print &AF_INET, "\n"; }

1;
----------------------------------------------------------------------

This prints out the following output with perl version 5.000:

----------------------------------------------------------------------

2
2
----------------------------------------------------------------------

It seems like it should at least print the same thing for all
invocations of &do_impl. Also, when &do consists of just "&do_impl();
&do_impl(1, 2)", everything works; but when the calls to &do_impl are
reversed, it fails with the same error as above.

It's entirely possible that I've installed perl5 incorrectly, because
I can't seem to find AF_INET.al anywhere.

---------------------------------------------------------------------------
Graham Spencer         | My birthstone is all eroded, my baby food was


--



Thu, 01 May 1997 13:47:32 GMT  
 Confusing behavior with 'use' and 'eval'

:
: Hello,
:
: I'm experiencing some odd behavior with 'use' and 'eval'. It's
: probably best to just share some code:
:
: ----------------------------------------------------------------------
: #!/usr/local/bin/perl5
:
: package main;
: &Bobo::do;
:
: package Bobo;
: use Socket;
:
: sub do {
:     eval { &do_impl(1, 2) };

:
:     eval { &do_impl(); };

:
:     eval { &do_impl(1, 2) };

: }
:
: sub do_impl { print &AF_INET, "\n"; }
:
: 1;
: ----------------------------------------------------------------------
:
: This prints out the following output with perl version 5.000:
:
: ----------------------------------------------------------------------

: 2
: 2
: ----------------------------------------------------------------------
:
: It seems like it should at least print the same thing for all
: invocations of &do_impl. Also, when &do consists of just "&do_impl();
: &do_impl(1, 2)", everything works; but when the calls to &do_impl are
: reversed, it fails with the same error as above.
:
: It's entirely possible that I've installed perl5 incorrectly, because
: I can't seem to find AF_INET.al anywhere.

No, you're okay--this is a known bug in 5.000.  A workaround is to
use AF_INET() instead of &AF_INET.  There is no AF_INET.al file,
nor should there be.  The value of AF_INET is taken from a C routine
named constant().  The AUTOLOAD routine that calls constant() has a bug

Once it works correctly, it continues working correctly because
it actually defines sub AF_INET {2}, like any good self-respecting
AUTOLOADer should do.

Larry



Tue, 06 May 1997 04:34:03 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. eval 'subs' used as #defines

2. What is pseudorandommy @chars=('a'..'z','A'..'Z','0'..'9','_');

3. Parser gets confused with '@' in strings

4. still confused about 'my'

5. Odd 'print @array' behavior with 4.035

6. Nasty 'do' behavior

7. Strange behavior with 'use'

8. Different browser behavior on '302 Redirect'

9. Returning information from 'eval'

10. 'die' outside eval returns 0

11. Getting 'eval' to shut up

12. alternative for 'eval'

 

 
Powered by phpBB® Forum Software