freelanceprogrammers.org Forum Index » Perl

Eval block not working


View user's profile Post To page top
the_land_baron Posted: Sat May 07, 2005 12:06 am


Joined: 07 May 2005

Posts: 1
Eval block not working
I have something along the line of:

# FILE1.pl
require "FILE2.pl";
eval { &function(); };
print "$@" if $@;
print "This never prints.
"

#FILE2.pl
sub function
{ die "A horrible death.
"; }


For some reason, I never get to the second print. I think the
first print isn`t happening either. The die seems to in fact, be
dieing, instead of getting trapped by eval as the book says.

Is there some magic trick I`m missing here? I`m using ActivePerl 5.8.

-Jerramy
Reply with quote
Send private message
View user's profile Post To page top
krish_tamil Posted: Sat May 07, 2005 10:50 am


Joined: 21 Feb 2005

Posts: 7
Eval block not working
Hi

You can try by removing the underscore before eval function i.e. eval {
&function(); }; not _eval….

and i suppose you have any other coding other than SubFunction in File2.pl
because if there is no process done in file2.pl the require will show error

see the $tmp in file2.pl


# FILE1.pl
require "FILE2.pl";
eval { &function(); };
print "$@" if $@;
print "This never prints.
"


#FILE2.pl
$tmp=1;
sub function
{ die "A horrible death.
"; }

Regards

Krishna

the_land_baron <jerramy@...> wrote:
I have something along the line of:

# FILE1.pl
require "FILE2.pl";
eval { &function(); };
print "$@" if $@;
print "This never prints.
"

#FILE2.pl
sub function
{ die "A horrible death.
"; }


For some reason, I never get to the second print. I think the
first print isn`t happening either. The die seems to in fact, be
dieing, instead of getting trapped by eval as the book says.

Is there some magic trick I`m missing here? I`m using ActivePerl 5.8.

-Jerramy







---------------------------------
Yahoo! Groups Links

To visit your group on the web, go to:
http://groups.yahoo.com/group/perl_official/

To unsubscribe from this group, send an email to:
perl_official-unsubscribe@yahoogroups.com

Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.


Yahoo! India Matrimony: Find your life partneronline.

[Non-text portions of this message have been removed]
Reply with quote
Send private message
View user's profile Post To page top
mikesouthern Posted: Sat May 07, 2005 3:34 pm


Joined: 16 Jun 2004

Posts: 9
Eval block not working
You already asked this. Do we have to endure the pain again?

On 5/6/05 3:06 PM, the_land_baron at jerramy@... wrote:

> I have something along the line of:
>
> # FILE1.pl
> require "FILE2.pl";
> eval { &function(); };
> print "$@" if $@;
> print "This never prints.
"
>
> #FILE2.pl
> sub function
> { die "A horrible death.
"; }
>
>
> For some reason, I never get to the second print. I think the
> first print isn`t happening either. The die seems to in fact, be
> dieing, instead of getting trapped by eval as the book says.
>
> Is there some magic trick I`m missing here? I`m using ActivePerl 5.8.
>
> -Jerramy
Reply with quote
Send private message
Post new topic Reply to topic
Display posts from previous:   
 

All times are GMT
Page 1 of 1
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Freelace Website Designer - Customer web design and software building.
China Wholesale - Electronics Products
Character Studio - Tutorials and Help