PDA

View Full Version : Reading top N lines from a file in a given directory


dbmadcap
06-24-03, 14:42
Hi All,

I have a folder/directory where I have all my Oracle sql scripts, useful for development & db administration. Every script contains comments, documentation in the top 5 lines or so. Sometimes the comments start with /* and end with */ and sometimes the initial lines start with -- which means comments/remarks in Oracle.

Now I want to write a perl/php script that will read all the files one-by-one from directory and pick the comments and write into a separate file so that I know what each script file does, without actually opening the script.

Its like I want to create a single file which contains contents/index for all the script files. Can somebody help me writing this script ?

Thanks in advance !

MattR
06-25-03, 11:21
Since this is something we have as well, I thought I'd try and take a stab at it.

Looking here:
http://search.cpan.org/author/ABIGAIL/Regexp-Common-2.113/lib/Regexp/Common/comment.pm

Althought it seems the {SQL}{MySQL} filter doesn't find /* */ comments correctly.

So I would think the best bet would be to use {SQL} to find -- comments, then try using {C} to find C-style comments /* */.

dbmadcap
06-25-03, 11:38
Sorry to say, but how do I use that ?