mkpath($homeDir, 0, 0077); chdir $homeDir; mkpath($tmpDir, 0, 0077); chdir $tmpDir; system qq{wget "$mainSite/$torrentSite"}; open FILE, $torrentFile; open CMD, "ls *torrent |"; close CMD; system qq{transmissioncli -ep --download-dir $homeDir/$tmpDir + --uplimit number 0 --config-dir $homeDir/$tmpDir $torrent &}; open CMD, "transmission-remote --list |"; close CMD; system "transmission-remote -t 1 -S &";

You should ALWAYS verify that these system calls performed correctly before trying to use code that relies on their results.



if (! -d $homeDir ) { print "Making $homeDir.\n"; mkpath($homeDir, 0, 0077); } print "Entering $homeDir.\n"; chdir $homeDir; if (! -d $tmpDir ) { print "Making $tmpDir.\n"; mkpath($tmpDir, 0, 0077); } print "Entering $tmpDir.\n"; chdir $tmpDir;

Why not just use one step:

unless ( -d "$homeDir/$tmpDir" ) { print "Making $homeDir/$tmpDir.\n"; my $err; eval { mkpath "$homeDir/$tmpDir", { verbose => 0, mode => 0077, e +rror => \$err }; }; if ( $@ or @$err ) { die "mkpath failed because: ", $@ || @$err; } } print "Entering $homeDir/$tmpDir.\n"; chdir "$homeDir/$tmpDir" or die "Cannot chdir to '$homeDir/$tmpDir +' because: $!";


eval $code or die $!;

The $! variable will not have any useful information from eval.    You need to use the $@ variable instead.



my @torrentFiles; open CMD, "ls *torrent |"; while (my $line = <CMD>) { chomp $line; push @torrentFiles, $line; } close CMD;

Or just:

my @torrentFiles = glob '*torrent';


In reply to Re: evaling code stored in database by jwkrahn
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.