anoopsaxena76:

It sounds to me like you want to iterate through an array of file names (foreach my $file (@files){), opening each with while(<>){ loops, parsing them for your comments, counting your contributions and moving on to the next. You'll want to open() and close() file handles for reading. You'll want to study a bit of regex for determining which lines you want to count and which you don't. And you'll need to write simple arithmatic operations to handle pointers and counts. The challenging thing here is that your markers for starting and ending your modifications are the same. But this sounds like a generally easy script to write.

All that begs the question, though? Have you been coding without a net? Couldn't something like this work for you:

cvs diff -rv.vvv -rv.vvv $filename
or, perhaps:
cvs log $filename
If not consider committing everything you've got to a revision control repository before you go any further. Some here likely use Subversion. I still use the old faithful cvs. The time coding this simple script might be better spent installing a repository on your network and reading the Cederqvist Manual, or the RedBean book or even practicing the commands from this useful crib sheet I've kept handy for the past couple of years.

The cvs log command gives useful reports that look like this for one of today's commits:

revision 1.9 date: 2006-05-25 06:57:55 +0000; author: hesco; state: Exp; lines: ++14 -6 added $port to interface of db connection routines. made another attempt to dynamically build connection parameters. commented it all out and left the hard-wired version running.
I think that is the information you are looking for: lines: +14 -6. I added fourteen lines and deleted six with that commit, compared to what was in the repository. Committing my work to cvs as I go permits me to then obtain useful reports such as the one you seek, from a bash command line, like so:
cvs log Registration/lib/Registration/WWW/RegForm.pm | grep lines: | g +rep 2006-05-24
yielding a quick summary of the day's work:
date: 2006-05-24 19:03:46 +0000; author: hesco; state: Exp; lines: ++4 -2 date: 2006-05-24 18:44:42 +0000; author: hesco; state: Exp; lines: ++41 -6 date: 2006-05-24 07:05:09 +0000; author: hesco; state: Exp; lines: ++33 -11
-- Hugh

if( $lal && $lol ) { $life++; }

In reply to Re: Best tool for my requirements? by hesco
in thread Best tool for my requirements? by anoopsaxena76

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.