#/usr/bin/perl # Usage: wrapman [files] ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst) = localtime(time); $month = (January,February,March,April,May,June, July,August,September,October,November,December)[$mon]; $user = $ENV{'USER'} || $ENV{'LOGNAME'} || (getpwuid($<))[0]; $fullname = (getpwnam($user))[6]; $fullname =~ s/.*-\s*(.*)\(.*//; $fullname =~ s/,.*//; substr($user,0,1) =~ tr/a-z/A-Z/; $fullname =~ s/&/$user/; # Propagate the & abomination. $log = '$' . 'Log' . '$'; $header = '$' . 'Header' . '$'; foreach $file (@ARGV) { # Generate various strings for the manual page. ($prog = $file) =~ s/\.\w+$//; ($PROG = $prog) =~ y/a-z/A-Z/; $Prog = $prog; substr($Prog,0,1) =~ y/a-z/A-Z/; # See if we really want to wrap this file. open(IN,$file) || next; $/ = "\n"; $line1 = ; next unless $line1 =~ /perl/; $line1 .= if $line1 =~ /eval/; $line1 .= if $line1 =~ /argv/; $line2 = ; next if $line2 eq "'di';\n"; # Pull the old switcheroo. ($dev,$ino,$mode) = stat IN; print STDERR "Wrapping $file\n"; rename($file,"$file.bak"); open(OUT,">$file"); chmod $mode, $file; # Spit out the new script. print OUT $line1; print OUT <; print OUT $line2, $_; # Now put the transition from Perl to nroff. # (We prefix the .00 below with $null in case the wrapman # program is itself wrapped.) print OUT <