But that's seems like a lot of extra typing:
Then in any part of your code where you use the database handle you
can say
sub foo {
my ($foo, $bar) = @_;
my $dbh = Project::DB::Handle->new;
my $sth = $dbh->prepare(...);
I started out with an HTML::Mason where I've shared $dbh via
On 2/20/06, The Ghost <[EMAIL PROTECTED]> wrote:
> I have defined $dbh (a database handle) as a global variable. I have
> a module, RD, that needs access to the database. How can I use $dbh
> within the RD module?
>
The best way to handle this is to create a singleton object to hold
the database
On 2/20/06, The Ghost <[EMAIL PROTECTED]> wrote:
> I have defined $dbh (a database handle) as a global variable. I have
> a module, RD, that needs access to the database. How can I use $dbh
> within the RD module?
Every global variable is in some package, in perl. If you haven't used
a package
Fontenot, Paul <[EMAIL PROTECTED]> wrote:
: EXAMPLE:
:
: while (my(@row) = $sth1->fetchrow_array)
: {
: my ($total) = $row[0];
: print "Total Scanned:\t $total\n";
: }
:
: print "Total:\t $total\n";
:
: After searching through the Perl Bookshelf CD
If you really want to use a BAD method, which you should NOT use:
while (...) {
$total = $row[0];
...
}
print $total . "\n";
What you SHOULD do is:
use strict;
...
my $total = "";
while (...) {
$total = $row[0];
...
}
print $total . "\n";
-David
On Tue, 17 Aug 2004 10:55:25
> After searching through the Perl Bookshelf CD, I have found that you can
> declare a global and then use local() to change that value for a block
> of code. I haven't found how to use a value from within a block of code
> outside that block of code though. Is this possible? I'm sure I just
> don'
> Hello world\n ;-)
>
> Im wondering about my perl. With this code:
> #!/usr/local/bin/perl
>
>
> use DBI;
> use strict;
>
> print "Test\n";
>
>
> ::$my_user = "blabla";
> my $password = "bloobbloob";
>
> my $logon = Adabas::logon("demo,adabas","mycomp:mydb");
>
> I got somethink like that:
Apologies:
I figured it out, some bad code outside the subroutine,
Thanks,
Matt
-Original Message-
From: Matthew Walkup [mailto:[EMAIL PROTECTED]]
Sent: Thursday, November 29, 2001 10:44 AM
To: [EMAIL PROTECTED]
Subject: RE: Globals in Subroutines (OOPS)
Some old code that i was
Some old code that i was testing with was accidently left in, the subroutine
is:
sub prepareandread_inputs {
foreach my $input (@inputs) {
if ($input->{gzip}) {
$input->{handler} = gzopen($input->{full_path}, 'r')
or die 'io;'.$input->{full_path} un