Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: Returning information from BEGIN

by arturo (Vicar)
on Feb 21, 2001 at 19:58 UTC ( #59947=note: print w/ replies, xml ) Need Help??


in reply to Returning information from BEGIN

You can export a symbol from BEGIN by the old use vars qw($foo); trick:

#!/usr/bin/perl -w BEGIN { use vars qw($foo); $foo = 'bar'; } use strict; print "$foo\n";

Does that help? Are you just trying to suppress the "BEGIN failed" message that pops up if you put the die in the BEGIN block? The use vars will help with that:

BEGIN { use vars qw($err); $err = $ENV{SM} ? 0 : 1; push @INC, "$ENV{SM}/../bin" unless $err; } die "Environment variable SM not set!\n" if $err; require 'error.pm';

Philosophy can be made out of anything. Or less -- Jerry A. Fodor


Comment on Re: Returning information from BEGIN
Select or Download Code
Re: Re: Returning information from BEGIN
by leons (Pilgrim) on Feb 21, 2001 at 20:02 UTC
    Thanks a lot arturo. And yep, that was exactly what I was
    trying to do ;-)

    Bye, Leon

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (13)
As of 2014-10-30 16:54 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls