Re: Find duplicates in a dat file



Dr.Ruud <rvtol+news@xxxxxxxxxxxx> wrote:

The first two lines of my smaller Perl scripts often look like:

[snip]


The first four lines of all of my Perl programs look like:

#!/usr/bin/perl
# prog_name - what prog_name does
use warnings;
use strict;


Because then when I can't find a program I remember writing
a long time ago, I just run the program below to make an
index of all of my Perl programs.


------------------------------------
#!/usr/bin/perl
# perl_program_index - make an index of all of my Perl programs
use warnings;
use strict;
use File::Find;

@ARGV = '.' unless @ARGV; # default to current directory

find \&perl_programs, @ARGV;

sub perl_programs {
return unless -f and -x _ and -T _; # consider only executable text files

open PROG, $_ or die "could not open '$_' $!";
return unless defined(my $shebang = <PROG>);
return unless defined(my $comment = <PROG>);
close PROG;

return unless $shebang =~ /^#!.*perl/; # not a perl program
return unless $comment =~ /^#\s*(\w+) - (.*)/; # not properly commented

print "$2\n $File::Find::name\n\n";
}
------------------------------------


--
Tad McClellan SGML consulting
tadmc@xxxxxxxxxxxxxx Perl programming
Fort Worth, Texas
.



Relevant Pages

  • Re: counting question.
    ... Add these two lines to the top of every one of your Perl programs: ... use warnings; ... Fort Worth, Texas ...
    (comp.lang.perl.misc)
  • Re: How to extract the HTML tag?
    ... snip> And it should handle other rare cases, ... And right there you showed why regexes are not good for parsing HTML ... use strict; ... use warnings; ...
    (perl.beginners)
  • Re: Beginner: read and print same file
    ... DATA after a keyword "% begin", but I am not finding the solution. ... use strict; ... use warnings; ...
    (comp.lang.perl.misc)
  • Re: debugger exiting
    ... Just because I am in a grumpy/contrary mood, ... strict and warnings pragmas. ...
    (perl.beginners)
  • Re: Strip HTML from files in a directory
    ... use strict; ... use warnings; ... for my $file (@ARGV) { ...
    (perl.beginners)