in reply to use strict and begin


You could use the vars pragma to declare a global variable. Or in Perl 5.6.0 or later you can use the our keyword:
#!/usr/bin/perl -w use strict; use vars '$dbh'; # In Perl >= 5.6.0: # our $dbh; BEGIN { $dbh = DBI->connect($DNS, "login", "password"); }

--
John.

Replies are listed 'Best First'.
Re: use strict ans begin
by Abigail-II (Bishop) on Jul 17, 2002 at 11:32 UTC
    Why would you want to use a package variable and not a lexical one?

    Abigail


      You are right. There isn't any obvious reason here to use a package variable instead of a lexical, except perhaps to demonstrate a hole in your knowledge. :-)

      I didn't know that you could declare a variable with my() before a BEGIN block as in your example.

      --
      John.