passing an argument to a subroutine
Posted on 2004-03-18
Hey guys quick help with some code if you could. Trying to pass an element of an array to a subroutine and having some troubles. can someone clean up my code. Also sorry for the way its written, im used to programming in Java or C++ so I comment everything. Also Id preffer it to be a refference passed even though the value will never change, id like to learn how to refference an array element as apposed to just storing its value in another variable and passing the new variable.
#Windows-based Perl/DBI/MS Access example
&openHTMLTags(); #Merely opens HTML Tags
@theTables = &tableNames(); #Works fine gets me a list of table names into an array.
&openTableHeadings(); #Prints HTML code for a table and its headings
print "$nameOfTable"; #prints out the table name just fine to make sure it works.
&getFields($nameOfTable); #PROBLEMS HERE!!!!
#// Pre: none
#// Post: Sql statments required to retrieve fields from database
print "$dataTableName"; #####WONT PRINT HERE!
#construct SQL statement
$sqlstatement="SELECT ID,FirstName,LastName,Company,Email,Location,Industry,Phone,Fax FROM $dataTableName";
#prepare and execute SQL statement
$sth = $dbh->prepare($sqlstatement);
die "Could not execute SQL statement, maybe invalid?";
} # end getFields()