Re: Working with Source Code to Insert Copyright Statements as a Header
- From: "Perlgirl" <sgordon@xxxxxxxxxxx>
- Date: 29 Aug 2006 08:12:04 -0700
Paul Lalli wrote:
Perlgirl wrote:
I was wondering if you could give me a hand.
Where could I go to find some samples of PERL code that do the
following:
What John's rather obnoxious remark meant was that the language is
spelled "Perl" and the interpreter is spelled "perl". There is no
"PERL".
1. inserts a particular copyright statement
2. checks the existing copyrights and updates it to include the current
year if it's not included
Or if the copyright has the wrong date, the script gives an error.
3. It has to process particular file types (I have that info); a
listing of files to process (I have that info too), and cannot process
binary files (have that info too)
Any help you can give me would be appreciated. Many thanks.
SRGordon
This isn't really the proper forum for your request. Generally, this
newsgroup helps people in writing and debugging their own code, not
finding other people's code.
Now, if you want some help actually *writing* the program you've
described, you're going to need to be a lot more clear. What do you
mean by "inserting a copyright statement"? Inserting it where? Into a
string? Into a file that's already opened? Into a file that is lying
on the disk somewhere?
Answer: Insertion of a copyright statement needs to only search through
all text_files
(*.c, .doc, .java, .xml, .pl, .sh. assembler_source, .txt .vbs .any
ascii english text, etc etc etc) at the top of the file, from a string:
"Copyright %Y CompanyName, Inc. All Rights Reserved." These files are
from the cvsroot vault, when a developer checks in his code. Think of
it as a ClearCase Trigger, but as a PERL wrapper for CVS. This string
also needs to be able to add to a current copyright date IF that date
is out of date, as
" Copyright 1999-2006 CompanyName, Inc All Right Reserved"; as well as
NOT change the existing date if the string already has "2006" in it.
Concurrently this string needs to be able to give an error if the
copyright has the wrong date (ex. 2007).
Any suggestions for this? Thanks so much. Perlgirl
What is meant by an "existing copyright"? Do you have a particular
pattern that represents a copyright notice?
I don't know for certain, but you might find Tie::File helpful. It's a
standard module as of Perl 5.8. If you have that version, you can type
`perldoc Tie::File` at the command line to read its documentation. If
not, you can search for it at http://search.cpan.org
I basically recommend: Opening each file you want to process, reading
it line-by-line and using pattern-matching to determine if the
copyright exists, using Tie::File to insert it where you want if it
doesn't, and using a search-and-replace if an incorrect one is found.
You should read:
perldoc perlre
perldoc -f open
perldoc -f readline
You should also read the Posting Guidelines that are posted to this
newsgroup twice a week. Following them maximizes your chances of
getting good help from this group.
Paul Lalli
.
- Follow-Ups:
- References:
- Prev by Date: Re: Working with Source Code to Insert Copyright Statements as a Header
- Next by Date: please helpme: Net-SNMP-5.2.0 module
- Previous by thread: Re: Working with Source Code to Insert Copyright Statements as a Header
- Next by thread: Re: Working with Source Code to Insert Copyright Statements as a Header
- Index(es):
Relevant Pages
|
|