in reply to Re^3: how to create a constant file and use it in other file
in thread how to create a constant file and use it in other file

This node was taken out by the NodeReaper on Aug 03, 2008 at 08:38 UTC
  • Comment on Reaped: Re^4: how to create a constant file and use it in other file

Replies are listed 'Best First'.
Re^5: how to create a constant file and use it in other file
by oko1 (Deacon) on Jul 16, 2008 at 03:05 UTC

    Here's a fairly simple method:

    # The 'source' file ("constants.plx") use constant { FOO => 1, BAR => 2, QUX => 3 };

    And in the code, when you want to use these constants:

    #!/usr/bin/perl -wl BEGIN { do "constants.plx"; } print "Foo: ". FOO. "\nBar: ". BAR. "\nQux: ". QUX;

    This results in

    Foo: 1 Bar: 2 Qux: 3

    For more info, see "perldoc constant" and "perldoc -f do" (the 'do EXPR' section.)

    
    -- 
    Human history becomes more and more a race between education and catastrophe. -- HG Wells
    

      This method is a work-around and it works well, indeed. However, it doesn't address the OP's exporting everything automatically request, IMHO.

      Update: See my proposal above.