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
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{ $@ =
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:
>
>
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
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
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 $@;
>>
>
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
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
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
- 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:
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
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
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
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
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";
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
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
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
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
On Thu, Sep 19, 2002 at 09:39:54AM +0100, Gary Stainburn wrote:
> I've got a problem understanding a scoping issue I've got.
http://perl.plover.com/FAQs/Namespaces.html is a good online resource for
learning about scoping.
> I've got 2 hashes which I defined inside the sub that generates the f
Gary Stainburn wrote:
> Hi all,
>
> I've got a problem understanding a scoping issue I've got.
>
> I've got 2 hashes which I defined inside the sub that generates the form
> thus:
>
> sub do_form() {
> my ($error)=@_;
> my %dships=('X'=>'','L'=>'Leeds','D'=>'Doncaster');
> my %depts=('X'
Hi all,
I've got a problem understanding a scoping issue I've got.
I've got 2 hashes which I defined inside the sub that generates the form thus:
sub do_form() {
my ($error)=@_;
my %dships=('X'=>'','L'=>'Leeds','D'=>'Doncaster');
my %depts=('X'=>'','S'=>'Service','P'=>'Parts','T'=>'Rapid-
}
>$hash{$temp}->{'foo'} = 42;## now it works
>}
-Original Message-
From: Jeff 'japhy' Pinyan [mailto:[EMAIL PROTECTED]]
Sent: Tuesday, February 19, 2002 1:14 PM
To: Bradford Ritchie
Cc: [EMAIL PROTECTED]
Subject: Re: foreach() index scoping question
On Feb 19, Bradford Ritchie said:
>foreach my $elem (@long_list) {
>my $k="junk";
>foreach $k (keys %hash) {
> last if($elem =~ /$k/);## ok, I've got the $k I need
>}
>$hash{$k}->{'foo'} = 42;## oops, $k is reset to "junk"
>}
That behavior is documented, yes.
P
Hi,
I want to use a foreach loop to iterate over a list but I want to be able to
retain the index variable when the loop ends (either at the end of the list
or by an early-exit "last" statement).
Given the following example code:
#!/usr/bin/perl -w
use strict;
my %hash = ( "one" => {},## T
25 matches
Mail list logo