1. when using eval, you want to check the status of $@ ( and not $? as you have in your snippet )
  2. system calls don't throw errors that you can check with eval.
  3. system returns 0 on success.
  4. $? and $!, which one is which, I tend to have to check the docs.

    system

    We can define our own system call that will throw an error (die) on failure.

    Quick example:

    sub my_system { system($_[0]) || die "$_[0] failed : $!"; } eval { my_system( "cp xyz.dat abc.dat" ); my_system("cp xyz.dat2 abc.dat2"); } if ($@) { print "Error occured : $@\n" }

    In reply to Re: Perl exception - multiple statement by spazm
    in thread Perl exception - multiple statement by pradeepbstays

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



  5. Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  6. Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  7. Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  8. Please read these before you post! —
  9. 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
  10. 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;
  11. Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  12. See Writeup Formatting Tips and other pages linked from there for more info.