Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: Re: Returning information from BEGIN

by leons (Pilgrim)
on Feb 21, 2001 at 21:15 UTC ( #59968=note: print w/ replies, xml ) Need Help??


in reply to Re: Returning information from BEGIN
in thread Returning information from BEGIN

Okay, here is what I did:

BEGIN { use vars qw($Bgn); $Bgn=1 unless $ENV{'SM'}; push @INC,$ENV{'SM'}||""."/../bin"; }; use strict; die "[Error] Environmental string not found: \$SM\n" if $Bgn; require 'errors.pm'; ... ...

To avoid getting the ugly Error-message when die-ing in the
BEGIN-block I wanted to set some variable which I would use
after the BEGIN-block to check whether there was an error.
In this case the error would have been the fact that the $SM
environment string hadn't been set. Which would result in
an error message in the BEGIN-block
Use of uninitialized value in concatenation (.) at ./test.s line 19
(Which was solved by the '||""'). And which would result in
an error message due to the require 'errors.pm';
Which could not be found in $SM/../bin/, because $SM hadn't
been set.

But fortunately, things are working now ;-)

Thanks and Bye, Leon


Comment on Re: Re: Returning information from BEGIN
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://59968]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (7)
As of 2015-07-04 06:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (57 votes), past polls