Re: globals and modules

2006-02-20 Thread The Ghost
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

Re: globals and modules

2006-02-20 Thread Chas Owens
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

Re: globals and modules

2006-02-20 Thread Tom Phoenix
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

RE: globals

2004-08-17 Thread Charles K. Clarkson
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

Re: globals

2004-08-17 Thread David Greenberg
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

Re: globals

2004-08-17 Thread Wiggins d Anconia
> 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'

Re: globals at dbi

2004-06-14 Thread Wiggins d Anconia
> 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:

RE: Globals in Subroutines (OOPS)

2001-11-29 Thread Matthew Walkup
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

RE: Globals in Subroutines (OOPS)

2001-11-29 Thread Matthew Walkup
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