#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);