#!/usr/bin/perl -w #) { chomp; process($_); } } exit(0); #--------------------------------------------------------------------- # Process a given string. sub process { my $str = shift; my $sig; s,//*$,,g; $sig = $options{'x'} ? md5_hex($_) : md5_base64($_); $options{'s'} ? print "$sig\n" : print "$sig $_\n"; } #--------------------------------------------------------------------- # Print a usage message from the comments and exit. sub usage { my ($emsg) = @_; use Pod::Usage qw(pod2usage); warn "$emsg\n" if defined $emsg; pod2usage(-verbose => 99, -sections => "NAME|SYNOPSIS|OPTIONS"); } sub manpage { use Pod::Man(); my $parser = Pod::Man->new(); open(STDOUT, "| groff -T ascii -man | gcat -s | less") || die "groff\n"; $parser->parse_from_file($0); close STDOUT || die "$myname: can't close stdout: $!\n"; $? = 1 if $? == 255; # from die exit($?); } #--------------------------------------------------------------------- # Print the UUID, current version, or source location. sub myuuid { my $UUID = sprintf("%s", q$UUID: a882ed05-2ec6-3fbf-bce0-3bac3af1b159 $ =~ /UUID: (.*) /); print "$UUID\n"; exit(0); } sub version { my $VERSION = sprintf("%d.%02d", q$Revision: 1.4 $ =~ /(\d+)\.(\d+)/); my $DATE = sprintf("%s", q$Date: 2009/02/07 23:25:09 $ =~ /Date: (.*) /); print "$myname $VERSION $DATE\n"; exit(0); } sub where { my $SOURCE = sprintf("%s", print "$SOURCE\n"; exit(0); } #--------------------------------------------------------------------- __END__ =head1 NAME path2sig - writes MD5 signature for each line read =head1 SYNOPSIS path2sig [-hmsuvwx] [file ...] =head1 OPTIONS =over 4 =item B<-h> Print a brief help message and exit. =item B<-m> Print the manual page and exit. =item B<-s> Print only the signatures. =item B<-u> Print the script UUID and exit. =item B<-v> Print the version and exit. =item B<-w> Print the source location and exit. =item B<-x> Print the signature in hex instead of base64. =back =head1 DESCRIPTION B reads pathnames and writes base64 MD5 hash of each one. Trailing slashes are trimmed from filenames for consistency. If filenames are present on the command line, the filenames are hashed and printed, NOT their contents. =head1 AUTHOR Karl Vogel Oasis Systems, Inc. =cut