Hi siberia-man,

I would advise you against using new in this context because it looks like an object constructor (and you module is not object-oriented).

Below are some further comments after a very quick look at your code (but maybe I looked at it to quickly).

If you made your module subroutine names a bit more specific, you could export them with a more limited risk of a name clash and then you could use them without having to prefix them with indent::. I would clearly be reluctant to use a module where I have to prefix all my sub calls with the module name. And, BTW, the module name should rather be Indent, with a leading capital letter. Do you really have to use the magical goto construct where, it seems to me, a simple function call would do?

That's an implementation detail, but if I were to write such a module, I think I would rather implement the current indentation as a simple scalar variable recording the indentation level, e.g. 0 for no indentation, 1 for the first level, etc., and then just increment or decrement that variable when changing indentation level, rather than having an array of strings with push and pop operations. But that is really a detail, nobody really cares.


In reply to Re: Simple indentation. Does it need improvement? by Laurent_R
in thread Simple indentation. Does it need improvement? by siberia-man

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.