Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number

Re: Line-counts of perl programs/modules

by Tarka (Novice)
on Apr 30, 2001 at 08:02 UTC ( #76543=note: print w/replies, xml ) Need Help??

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.

Log In?

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://76543]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (5)
As of 2022-08-08 06:43 GMT
Find Nodes?
    Voting Booth?

    No recent polls found