develooper Front page | perl.perl5.porters | Postings from July 2012

Re: [perl #114178] di/ds/ig exempt from warnings in void context

Thread Previous
From:
Tom Christiansen
Date:
July 18, 2012 15:29
Subject:
Re: [perl #114178] di/ds/ig exempt from warnings in void context
Message ID:
133.1342650566@chthon
Ricardo Signes <perl.p5p@rjbs.manxome.org> wrote
   on Wed, 18 Jul 2012 17:33:17 EDT: 

>* Leon Timmermans <fawaka@gmail.com> [2012-07-18T14:38:37]
>> Considering this is a warning that has to be enabled explicitly, and
>> that we're talking about perl 4 compatibility here, I wouldn't care
>> too much about such a minor break of backwards compatibility. I'd be
>> surprised if this was the first time in the past 18 years that such a
>> thing happened.

> I agree.

I can't get myself worked up over this, as I have only a dozen
scripts that actually make use that, so only ~1.3% of my scripts
dir. I don't know that I actually wrote any of them myself; they
all look like 20 years old.  For example, I think the one included
below my sig is actually Larry's.

As for being und(er)ocumented, well, you do have leave *something*
for the Perl Pub Quiz, you know:

    http://www.foo.be/docs/tpj/issues/vol2_4/tpj0204-0013.html

Just kidding.  Mostly.  Anyway, there are other things to find 
that are more fun to put there, and more educative, too.

No, it's not in the book.  As Larry himself remarked...

    It won't be covered in the book.  The source code has 
    to be useful for something, after all...  :-)
		 --Larry Wall in <10160@jpl-devvax.JPL.NASA.GOV>

--tom

    #!/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 = <IN>;
	next unless $line1 =~ /perl/;
	$line1 .= <IN> if $line1 =~ /eval/;
	$line1 .= <IN> if $line1 =~ /argv/;
	$line2 = <IN>;
	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 <<EOF;
    'di';
    'ig00';
    #
    # $header
    #
    # $log
    EOF

	# Copy entire script.

	undef $/;
	$_ = <IN>;
	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 <<EOF;
    ###############################################################

	# These next few lines are legal in both Perl and nroff.

    $null.00;                       # finish .ig
     
    'di           \\" finish diversion--previous line must be blank
    .nr nl 0-1    \\" fake up transition to first page again
    .nr % 0         \\" start at page 1
    '; __END__ ##### From here on it's a standard manual page #####

    .TH $PROG 1 "$month $mday, 19$year"
    .AT 3
    .SH NAME
    $prog \\- whatever
    .SH SYNOPSIS
    .B $prog [options] [files]
    .SH DESCRIPTION
    .I $Prog
    does whatever.
    .SH ENVIRONMENT
    No environment variables are used.
    .SH FILES
    None.
    .SH AUTHOR
    $fullname
    .SH "SEE ALSO"

    .SH DIAGNOSTICS

    .SH BUGS

    EOF

	close IN;
	close OUT;
    }

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About