http://qs321.pair.com?node_id=76543


in reply to Line-counts of perl programs/modules

A lot of people have replied with something equivalent to "It depends what you're trying to measure." In my case I was cleaning up some legacy database code left by a programmer with a particularly bad case of the cut-n-paste coding style. I was abstacting the low-level routines, and was curious to how much I was actually able to remove from the other routines.

I got to wondering what people actually measured when called upon. In the end in just took a guestimate with "egrep -c '}|;' <filename>".

Of course, line-count (high or low) by itself means nothing. Don't worry, I fudged a few in my military programming days ;)

Thanks to all for the replies.

  • Comment on Re: Line-counts of perl programs/modules

Replies are listed 'Best First'.
Re: Re: Line-counts of perl programs/modules
by snafu (Chaplain) on May 02, 2001 at 11:23 UTC
    Why are you counting your close curly braces? Wouldn't it be better to just count the ';'s? If you are like me and comment a lot (even comment out lines of code for later use) you might want to grep out the '#'s too then count the ';'s.

    I still can't think of why you would count the close curlies though.

    egrep -v '^#' file | egrep -e ';$' | wc -l

    ----------
    - Jim

      I count the braces so that conditionals and loops count as a line apeice. Admittedly that pulls in subs too (and anonymous hashes, if their closing brace doesn't end on the same line as the semi). It's just a personal preference.