What are you doing to eval the code? I don't see the word eval anywhere in the posted script. Is this the code you are trying to eval? Or are you refering to your attempt to insert code into the database in what looks like code samples at the end of each of your "execute" calls?

If the entire script is what you are eval'ing, as a first step make sure the script works without escaping or quoting when placed in a file and run as a normal script. I suspect it doesn't even compile. One you get it to compile, if you still have trouble, come back. However, post the code you use to eval the script, not the script itself. Without knowing what you are doing to "eval", we can't even begin to troubleshoot with you.

If, what you mean by "eval" is that you are having trouble passing in the code samples as the final line of each call to execute, I don't see any starting or ending quotes around those code samples. Perl is reading that as part of your script and not as a string of code to pass to bit-torrent. You need to consruct a string containing the code and then pass the the string to your execute call, e.g.

#This string is single quoted with q{...} so you don't # need to "escape" parenthesis or dollar signs # Also you can nest q{...}, but not '....'. so it is more # reliable my $sCode=q{ if ($line =~ /href=\"(.*)\"/) { print "Fetching torrent file: $mainSite/$1.\n"; system qq{wget "$mainSite/$1"}; } }; # alternatively, you can use a here doc with the end tag # in single quotes. Putting '...' around the end tag tells # perl to treat all of the text within verbatim so there is # no need to escape individual characters $sCode=<<'EOF'; if ($line =~ /href="(.*)") { print "Fetching torrent file: $mainSite/$1.\n"; system qq{wget "$mainSite/$1"}; } EOF # run command with _string_ variable containing code my $q = $queries{insertBittorrent}; $q->execute( 'http://www.slackware.com', 'getslack/torrents.php', 'torrents.php', 'install-dvd',' $sCode);

In reply to Re: evaling code stored in database by ELISHEVA
in thread evaling code stored in database by mhearse

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.