in reply to Best tool for my requirements?
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:
or, perhaps:cvs diff -rv.vvv -rv.vvv $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.cvs log $filename
The cvs log command gives useful reports that look like this for one of today's commits:
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: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.
yielding a quick summary of the day's work:cvs log Registration/lib/Registration/WWW/RegForm.pm | grep lines: | g +rep 2006-05-24
-- Hughdate: 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
|
|---|