Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: How do I write data in SQLite

by GhodMode (Pilgrim)
on Feb 04, 2006 at 00:00 UTC ( [id://527862]=note: print w/replies, xml ) Need Help??


in reply to How do I write data in SQLite

Since you know it's on the alert line, you know that the problematic variable is $_ (the current element of @links), or $text[$v]. You know it's not $a or $v because you set them explicitly before the loop starts.

Use some print statements on separate lines for each of those variables to see what they contain. When you try to print the one that's uninitialized, you'll get the error message again and you'll know which one is causing the problem.

What to do after you find the problematic variable depends on your needs. You could just initialize them all to "" at the beginning of the loop and that would make the error message go away, but you might not want any of those fields to be blank.

Here's another method

while(@links) { $_ ||= ""; $text[$v] ||= ""; $dbh->do( "INSERT INTO webpages_data VALUES('$a', '$_', '$text[$v] +', NULL)"); $a++; $v++; }

||= says, for example: if ( ! $text[$v] ) { $text[$v] = "" };

--
-- GhodMode

Replies are listed 'Best First'.
Re^2: How do I write data in SQLite
by chromatic (Archbishop) on Feb 04, 2006 at 03:56 UTC
    ...you know that the problematic variable is $_ (the current element of @links)

    But it's not the current element of @links; that's the problem!

Re^2: How do I write data in SQLite
by lampros21_7 (Scribe) on Feb 04, 2006 at 00:58 UTC
    Thanks to everyone for their answers!! Update: For some reason the SQLite Analyser program for showing the contents of the database wouldn't bring up the table properly. I have used SQLite Plus and that works perfectly.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://527862]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (5)
As of 2024-04-19 03:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found