in reply to Re^3: split a line into 2 variables and store in SQL
in thread split a line into 2 variables and store in SQL

Hi Bloodnok, Thanks for your reply...I have a file in which i have data..
word1 := word2; word3 <= word4; word5 <= word6;
And i have to read this... such that i read word1, word3, word 5.. etc in same variable so that i should be able to transfer this data into a SQL table. And as far as i knw, we can transfer any data into the sql. Thanking you,

Replies are listed 'Best First'.
Re^5: split a line into 2 variables and store in SQL
by Bloodnok (Vicar) on Jan 23, 2009 at 11:27 UTC
    ...but you can only update an SQL table using an SQL UPDATE statement e.g.
    UPDATE table SET foo = bar WHERE condition
    browsing SQL should start you off.

    BTW, you do realise that the split you perform won't work with word1 := word2; since the value you split on doesn't exist, try /\s*.=\s/* as the regex - in that way, you'll remove white space either side of the tokens you actually want.

    Alternatively, just use vanilla split and use the 1st and 3rd elements of the resulting array e.g.

    while (<>) { my @args = split; # Now use $args[0] & $args[2] as appropriate . . }

    A user level that continues to overstate my experience :-))