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
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |