I was able to figure it out. Here is the update (probably not final) code for anyone interested:
[code] #! /usr/bin/perl # use DBI; use DBD::mysql; use Text::CSV; use strict; #configure variables my $host = "localhost"; my $db = "global_stats"; my $table = "station_information"; my $user = "globalstats"; my $password = "algoreliesLOL"; #connect to the database my $dbc = "dbi:mysql:$db:$host"; my $dbh; if($dbh = DBI->connect($dbc, $user, $password) or die "Can't connect to the database: $DBI::errstr\n") { print "Connected to the database!"; } #setup parser my $csv = Text::CSV->new(); print "What is the name of the file? (<ENTER> for default) : "; chomp(my $file = <STDIN>); if($file -eq "\n") { $file = '/home/jmd9qs/global_stats/ish-history.csv'; } open CSV, "<", $file or die "Can't open the file \"$file\": $!"; while(<CSV>) { next if ($. == 1); if ($csv->parse($_)) { my @columns = $csv->fields(); my $myquery = $dbh->do("insert into station_information (station_number,WBAN_number,station_name,country,fips,state,ICAO_callsign,lattitude,longitude,elevation) values (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)", {}, $columns[0], $columns[1], $columns[2], $columns[3], $columns[4], $columns[5], $columns[6], $columns[7], $columns[8], $columns[9]); } else { my $err = $csv->error_input; print "Failed to parse line: $err"; } } close CSV; $dbh->disconnect(); [\code] Thanks again for the help. jmd9qs On Sun, Nov 7, 2010 at 9:25 PM, J M <jmd...@gmail.com> wrote: > Ok now that John has helped me realize that I've been acting like a fool > for the past 3 hours, I'm getting this error: > > DBD::mysql::st execute failed: MySQL server has gone away at [whatever line > number] > > Thanks for your help, guys... currently I'm changing the script to use > placeholders and $dbh->do() instead of $dbh->prepare() and $dbh->excecute(). > I'll post updated code when that is done. > > > > > On Sun, Nov 7, 2010 at 8:58 PM, John W. Krahn <jwkr...@shaw.ca> wrote: > >> J M wrote: >> >>> ---------- Forwarded message ---------- >>> From: J M<jmd...@gmail.com> >>> Date: Sun, Nov 7, 2010 at 8:27 PM >>> Subject: Re: error opening file with open function >>> To: shawn wilson<ag4ve...@gmail.com> >>> >>> >>> shawn, >>> >>> I pretty sure it's not a permissions thing but here you go: >>> >>> [code] >>> (jmd...@darkstar)-(0)-(07:23 PM Sun Nov 07)-> >>> (~/global_stats)-(5 files, 2.4Mb)--> ls -lh >>> total 2.3M >>> -rw-r--r-- 1 jmd9qs sys 203 2010-11-07 12:10 globals.php >>> -rwxr-xr-x 1 jmd9qs sys 1.6K 2010-11-07 18:50 globals.pl* >>> -rwxr-xr-x 1 jmd9qs sys 1.6K 2010-11-07 18:48 globals.pl~* >>> -rw-r--r-- 1 jmd9qs sys 864 2010-11-07 12:39 import.php >>> -rwxrwxrwx 1 jmd9qs sys 2.3M 2010-11-07 14:15 ish-history.csv* >>> >>> (jmd...@darkstar)-(0)-(07:23 PM Sun Nov 07)-> >>> (~/global_stats)-(5 files, 2.4Mb)--> whoami >>> jmd9qs >>> [\code] >>> >>> >>> And here's the error I get >>> >>> >>> [code] >>> (jmd...@darkstar)-(0)-(07:23 PM Sun Nov 07)-> >>> (~/global_stats)-(5 files, 2.4Mb)--> ./globals.pl >>> Connected to the database!What is the name of the file (probably >>> /home/jmd9qs/global_stats/ish_history.csv)? : >>> /home/jmd9qs/global_stats/ish_history.csv >>> Can't open the file "/home/jmd9qs/global_stats/ish_history.csv": No such >>> file or directory at ./globals.pl line 28,<STDIN> line 1. >>> >>> (jmd...@darkstar)-(0)-(07:25 PM Sun Nov 07)-> >>> (~/global_stats)-(5 files, 2.4Mb)--> >>> [\code] >>> >> >> Your file is named 'ish-history.csv' (with a hythen between 'ish' and >> 'history') but you are trying to open 'ish_history.csv' (with an underscore >> between 'ish' and 'history'). >> >> >> >> John >> -- >> Any intelligent fool can make things bigger and >> more complex... It takes a touch of genius - >> and a lot of courage to move in the opposite >> direction. -- Albert Einstein >> >> -- >> To unsubscribe, e-mail: beginners-unsubscr...@perl.org >> For additional commands, e-mail: beginners-h...@perl.org >> http://learn.perl.org/ >> >> >> >