in reply to Re: Re: Re: Re: Modifying Perl script to write to MySQL??
in thread Modifying Perl script to write to MySQL??

$guestbookreal just holds the path and name of the file where your script will store the SQL-string you need to execute later: it does not hold this SQL-string itself directly.

So what you need to do is to open this file and read it, put its contents in a scalar variable and execute that.

I know, I know, it seems awfully convoluted and difficult and there is for sure a much more easy other solution available, but that would involve a major rewrite of your script. Then again, any rewrite of one of Matt's script is probably a "good thing™".

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

  • Comment on Re: Re: Re: Re: Re: Modifying Perl script to write to MySQL??

Replies are listed 'Best First'.
Re: Re: Re: Re: Re: Re: Modifying Perl script to write to MySQL??
by bobafifi (Beadle) on Feb 16, 2004 at 15:27 UTC
    I guess what I'm not getting a clear picture of maybe described like this:

    If the current output to the HTML page from $guestbookreal = "/home/flute/usedflutes-www/new_listings_publish.html"; (http://www.usedflutes.com/new_listings_publish.html is producing a string that I can literally copy & paste, drop into a GUI, and hit "GO" adds a new record to MySQL without any problem, then isn't there a syntax equivalent for that move - or is that not possible??

    Thanks once again for your help (and patience with me!) with this CountZero,

    -Bob
      Yes of course there is: just take the content of "/home/flute/usedflutes-www/new_listings_publish.html", put it in a scalar variable and give it to $sth=$dbh->prepare($yourscalarvariable); $sth->execute();

      CountZero

      "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

        I'm not sure I understand what you mean by "content?"
        Isn't this is a variable - just a string which changes with each new ad??

        If so, then I keep imagining an equation which might be expressed something like this (and I know this can't be right...)

        $guestbookreal=$sth=$dbh->prepare($guestbookreal);
        $sth->execute();

        yikes!...   :-|

        -Bob
        OK - looking around on the Web, I've found three "content->scalar" equations:
        { local $/; $content = <HANDLE> } ===== open FILE, "inputfile" or die "Couldn't open file"; $content.=<FILE> close FILE; ===== open FILE, 'inputfile' or die "Could not open file inputfile: $!"; sysread(FILE, my $content, -s FILE); close FILE or die "Could not close file: $!";
        Is this what you're referring to and if so, can you please recommend which one of the above I should try using?

        Thanks again,

        -Bob