in reply to Comparison based on type of value held by variables
Reinventing the wheel is often a good learning experience. It looks like your are writing your own join function. But Perl already has evolved from wheel to pneumatic tire :-) With DBD::AnyData your code should basically collapse into SQL statements. From perldoc DBD::AnyData.pm :
$dbh->func( 'classes', 'CSV', 'classes.csv' 'ad_import'); $dbh->func( 'profs', 'XML', 'profs.xml', 'ad_import'); my $classes_sth = $dbh->prepare( "SELECT pid,title FROM classes" ); my $profs_sth = $dbh->prepare( "SELECT name FROM profs WHERE pid = +?" ); $classes_sth->execute; while (my($pid,$class_title) = $classes_sth->fetchrow_array) { $profs_sth->execute($pid); my $row = $profs_sth->fetchrow_arrayref; my $prof_name = $row ? $row->[0] : ''; print "$class_title : $prof_name\n"; } That will produce the same results as: SELECT classes.title,profs.name FROM classes,profs WHERE pid = pi +d
|
|---|