At 01:29 PM 5/23/01 -0700, you wrote:
>I'm not sure what you mean by "multiple namespaces". Could you
>elaborate?

I am writing a module.  This module has numerous packages which are what I 
am referring to (perhaps erroneously)  as namespaces.  In this module file 
is a use pragma/function that tells the module to use another, which was 
written by some colleagues who get the big bucks for their know-how and 
experience, and therefore I'm sure they blessing objects :-)
(even I figured out how to do that and this is the first time I'm writing 
any object-oriented perl or modules).  I just checked up on them, and yes 
their code blesses the object.

>Also, I'm prompted to ask exactly what is the code of Class::new()
>What *exactly* is the object? Has it been bless()'d?

See above

>I'd have to see it.

Ok, so here is some code.

#!/usr/local/bin/perl5 -w
use strict;

require "request_sub.lib";      #this is the file that contains the 
subroutine I will want to                           #pass the object to
my $configFile = "lib/request.conf";
my %conf = ();
my $varValueSep = '==';
my $confComment = '#';

processConfFile (\$configFile, \%conf, \$varValueSep, \$confComment);
use NYT::Cnxdb;
my $cnxdb = Cnxdb->new($conf{cnxdbUser},$conf{cnxdbPort},$conf{cnxdbTimeout});
die("Unable to connect to database: " . $cnxdb->getlasterror())
    unless $cnxdb->getok();a
#cnxdb is the object in question.  It is in the main package of the module file
--------------------------------Break in 
Code------------------------------------------------
sub new_request_form {

    my $class = shift;
    my @values;
    if ($class eq "BugTrack") {
         $query =<<EoQ;
         select DISTINCT ED_LASTNAME,ED_FIRSTNAME,ED_EMPLOYEEID from 
NYT_EMPLOYEE_DIR
         where ED_LOCATIONID = 1 and ED_EMP_STATUS <> 2
         order by ED_LASTNAME
EoQ
    $query =~ s#\s+# #g;
    (my $status,my $error, @values) = $cnxdb->execute("$query");
    } else {
         my %responsibility = (
            'DBTrack' => 10,
            'SysTrack' => 9,
            'DevTrack' => 8,
         );

       @values = &select_people($cnxdb,$responsibility{$class});  #here is 
where I pass 
the                                                              #object to 
the 
subroutine, 
#which lives in separate file
    }
    my $requestors = "";
    foreach (@values) {
         my $firstname = ucfirst $$_{ED_FIRSTNAME};
         my $lastname = ucfirst $$_{ED_LASTNAME};
         my $employeeid = $$_{ED_EMPLOYEEID} or $$_{PR_EMPLOYEEID};
         $requestors .=qq#<option value="$employeeid">$firstname 
$lastname</option>#;
    }
    my $defaults = {'class' => "$class",
                    'req_date' => _date,
                    'requestors' => "$requestors",
                   };
    my $confile = "newRequest$class";
    print Template::getAsString("$conf{$confile}",$defaults,$err);

};


And in the other file (request_sub.lib):

sub select_people {

   my ($cnxdb,$responsibility) = @_;  #lexical copies of parameters
   my $query = <<EoQ;
   select ED_FIRSTNAME,ED_LASTNAME,PR_EMPLOYEEID
   from NYT_EMPLOYEE_DIR,NYT_PEOPLE_RESPONSIBILITIES
   where (ED_EMPLOYEEID = PR_EMPLOYEEID)
   and PR_RESPONSIBILITY_ID = $responsibility
   and ED_EMP_STATUS <> 2
   order by ED_LASTNAME
EoQ

   $query =~ s#\s+# #;
   my ($status, $error, @names) = $cnxdb->execute("$query");
#here is where I attempt to access the object method to no avail
   return @names;

}

Thanks for all your help!
Peter Cline
Inet Developer
New York Times Digital

Reply via email to