Re: Eval scoping question

2009-12-13 Thread C.DeRykus
On Dec 11, 10:52 am, rvtol+use...@isolution.nl (Dr.Ruud) wrote: > C.DeRykus wrote: > > Dr.Ruud: > >> C.DeRykus: > >>>      eval { asub() }; > >>>      die $@ if $@; > > >> You need to test the return of eval itself to be sure. > > ... > perl -wle ' > >    die "An error: ", $@ || "whoopy" >      i

Re: Eval scoping question

2009-12-12 Thread Dr.Ruud
C.DeRykus wrote: Dr.Ruud: C.DeRykus: eval { asub() }; die $@ if $@; You need to test the return of eval itself to be sure. Example: perl -wle ' die "An error: ", $@ || "whoopy" if !eval{ asub(); 1 }; sub asub{ my $x = bless {}, "main"; 1 / 0 } sub DESTROY{ $@ =

Re: Eval scoping question

2009-12-11 Thread C.DeRykus
On Dec 10, 1:21 pm, rvtol+use...@isolution.nl (Dr.Ruud) wrote: > C.DeRykus wrote: > > On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote: > >> On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote: > >> Also, in this case, I'd write the eval for compile-time and check > >> for errors: > >

Re: Eval scoping question

2009-12-10 Thread C.DeRykus
On Dec 10, 12:57 pm, shawnhco...@gmail.com (Shawn H Corey) wrote: > C.DeRykus wrote: > > On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote: > >> On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote: > > >>> ... > > >> ... > >> Also, in this case, I'd write the eval for compile-time and

Re: Eval scoping question

2009-12-10 Thread Dr.Ruud
C.DeRykus wrote: On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote: On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote: Also, in this case, I'd write the eval for compile-time and check for errors: eval { asub() }; die $@ if $@; No, sorry, that's a "useless use of

Re: Eval scoping question

2009-12-10 Thread Shawn H Corey
C.DeRykus wrote: > On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote: >> On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote: >> >>> ... > >> ... >> Also, in this case, I'd write the eval for compile-time and check >> for errors: >> >> eval { asub() }; >> die $@ if $@; >> >

Re: Eval scoping question

2009-12-10 Thread C.DeRykus
On Dec 8, 1:57 am, dery...@gmail.com (C.DeRykus) wrote: > On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote: > >> ... > ... > Also, in this case, I'd write the eval for compile-time and check > for errors: > >      eval { asub() }; >      die $@ if $@; > No, sorry, that's a "useless us

Re: Eval scoping question

2009-12-09 Thread C.DeRykus
On Dec 8, 12:08 am, an...@melerit.se (Anders Hartman) wrote: > Hello, > > I which to use eval to execute subroutines dynamically. > > The following code snippet fails: > > #!/usr/bin/perl > > use strict; > use warnings; > > sub asub { >    our $abc; >    print $abc; > > } > > my $abc = "abc\n"; > e

Re: Aw: Re: Eval scoping question

2009-12-08 Thread Shawn H Corey
pa...@arcor.de wrote: > Well, the OP said the method name is changing during the running time, so he > want to eval the method name. > So a AUTOLOAD method is right for him as far as I can think. AUTOLOAD introduces the possibility of code injection. So does eval. If the code is running on a ser

Aw: Re: Eval scoping question

2009-12-08 Thread pangj
- Original Nachricht Von: Shlomi Fish An: beginners@perl.org Datum: 08.12.2009 12:08 Betreff: Re: Eval scoping question > On Tuesday 08 Dec 2009 12:18:10 Jeff Pang wrote: > > Shlomi Fish: > > > On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote:

Re: Eval scoping question

2009-12-08 Thread Shlomi Fish
On Tuesday 08 Dec 2009 12:18:10 Jeff Pang wrote: > Shlomi Fish: > > On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote: > >> Shlomi Fish: > >>> Regarding using string eval "" - you can do the same using > >>> UNIVERSAL::can, which would be safer in this case: > >>> > >>> > >>> __PACKAGE__->can("a

Re: Eval scoping question

2009-12-08 Thread Jeff Pang
Shlomi Fish: On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote: Shlomi Fish: Regarding using string eval "" - you can do the same using UNIVERSAL::can, which would be safer in this case: __PACKAGE__->can("asub")->(@params); or define a package and use AUTOLOAD method? How will the AUTOL

Re: Eval scoping question

2009-12-08 Thread Shlomi Fish
On Tuesday 08 Dec 2009 11:46:59 Jeff Pang wrote: > Shlomi Fish: > > Regarding using string eval "" - you can do the same using > > UNIVERSAL::can, which would be safer in this case: > > > > > > __PACKAGE__->can("asub")->(@params); > > or define a package and use AUTOLOAD method? > How will

Re: Eval scoping question

2009-12-08 Thread Jeff Pang
Shlomi Fish: Regarding using string eval "" - you can do the same using UNIVERSAL::can, which would be safer in this case: __PACKAGE__->can("asub")->(@params); or define a package and use AUTOLOAD method? -- Jeff Pang http://home.arcor.de/pangj/ -- To unsubscribe, e-mail: beginner

Re: Eval scoping question

2009-12-08 Thread Erez Schatz
2009/12/8 Anders Hartman : >>> Hello, >>> I which to use eval to execute subroutines dynamically. >>> The following code snippet fails: >>> >>> #!/usr/bin/perl >>> >>> use strict; >>> use warnings; >>> >>> sub asub { >>>  our $abc; >>>  print $abc; >>> } >>> >>> my $abc = "abc\n"; >>> eval "asub";

Re: Eval scoping question

2009-12-08 Thread Shlomi Fish
On Tuesday 08 Dec 2009 11:03:44 Anders Hartman wrote: > Jeff Pang skrev: > > Anders Hartman: > >> Hello, > >> > >> I which to use eval to execute subroutines dynamically. > >> > >> The following code snippet fails: > >> > >> > >> #!/usr/bin/perl > >> > >> use strict; > >> use warnings; > >> > >> su

Re: Eval scoping question

2009-12-08 Thread Anders Hartman
Jeff Pang skrev: Anders Hartman: Hello, I which to use eval to execute subroutines dynamically. The following code snippet fails: #!/usr/bin/perl use strict; use warnings; sub asub { our $abc; print $abc; } my $abc = "abc\n"; eval "asub"; exit 0; I don't think you want an eval here

Re: Eval scoping question

2009-12-08 Thread Jeff Pang
Anders Hartman: Hello, I which to use eval to execute subroutines dynamically. The following code snippet fails: #!/usr/bin/perl use strict; use warnings; sub asub { our $abc; print $abc; } my $abc = "abc\n"; eval "asub"; exit 0; I don't think you want an eval here. use strict; use

Eval scoping question

2009-12-08 Thread Anders Hartman
Hello, I which to use eval to execute subroutines dynamically. The following code snippet fails: #!/usr/bin/perl use strict; use warnings; sub asub { our $abc; print $abc; } my $abc = "abc\n"; eval "asub"; exit 0; with the error: Use of uninitialized value in print at ... asub shoul