It seems like your code is just the right thing.

Generaly, anything that could be useful to other programs should be seperated into a module even if currently you use it only once. A good example is the function login().

similarly some snippets of code, even if only used once should be separated into functions if they do something useful. Beside helping readability, this gives you the ability to reuse in the future.

Say you used the login process only once, making the program die on login failure. Now you improve your program and you want to allow 3 trials, or allow the user to use your program anonimously and login only for certain features etc. Are you gonna re-write the login snippet of code? or transfer it to a function? Better to put it in a function in the first place.

It's like filing your bills when you get them instead of stocking a big pile and have lots of fun sorting them at the end of the year.


In reply to Re: When Is Dividing Code Into Different Subroutines/Packages Important? by yosefm
in thread When Is Dividing Code Into Different Subroutines/Packages Important? by Missing Words

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.