princepawn has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; use Data::Dumper; use DBIx::Connect; use DBIx::Recordset; my @database = (qw(horse1 SYNDB)); my $r = '/data/tbone/maldunn2'; my %tbl; $DBIx::Recordset::Debug = 2; *DBIx::Recordset::LOG = \*STDERR; sub tbl_srch { my ($fname, $lname) = @_; for my $db (@database) { while ( my ($table, $fields) = each %tbl ) { DBIx::Recordset->Search ({ '!DataSource' => DBIx::Connect->to($db), $fields->[2] => $fname, $fields->[3] => $lname }); } } } sub load_tbls { my $database = shift; open T, "$r/$database.tblmap-names-email-address"; while ( <T>) { my ($table, @field) = split; $tbl{$table} = \@field; } } warn Dumper(\@database); load_tbls $_ for (@database); die Dumper(\@database); tbl_srch 'John', 'Smith';
perl sql.pl $VAR1 = [ 'horse1', 'SYNDB' ]; $VAR1 = [ undef, undef ];
Carter's compass: I know I'm on the right track when by deleting something, I'm adding functionality.
| Replies are listed 'Best First'. | |
|---|---|
|
Re: use of $_ is destroying @database ... why?
by Abigail-II (Bishop) on Sep 24, 2003 at 20:11 UTC | |
|
Re: use of $_ is destroying @database ... why?
by premchai21 (Curate) on Sep 24, 2003 at 20:15 UTC | |
|
Re: use of $_ is destroying @database ... why?
by dragonchild (Archbishop) on Sep 24, 2003 at 20:18 UTC |