I'm trying to fix without using subroutines

I also tried subroutines but didn't work for me

You should try using subroutines without calling exit 0; all over the place.

You can use return to exit a subroutine, but if you're dealing with a callback, as with File::Find, that won't work as find will just keep calling it, again, and again, and again, as it was designed to do.

To escape File::Find::find you'll have to use goto LABEL as in

find( ... sub { goto END_OF_FILE_FIND; } ); END_OF_FILE_FIND: print "got 20 and quit\n";

You shouldn't use backticks all over the place, make a subroutine sub do_backup { and call it.

And you don't need to use backticks for everything, use abstractions (subroutines), see hostname site:perldoc.perl.org

If I were you, I would draw draw a plain ASCII diagram or flowchart of how this program is supposed to operate , it helps in organizing the program (what is a loop, what is a function ) -- it should be a statement of what you want to accomplish, it shouldn't reflect the peculiarities of how File::Find operates


In reply to Re: Break out of program to get correct logic (total count) by Anonymous Monk
in thread Break out of program to get correct logic (total count) by begood321

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.