Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!cs.utexas.edu!uunet!dino!ux1.cso.uiuc.edu!ux1.cso.uiuc.edu!uxc.cso.uiuc.edu!kailand!pwolfe From: pwolfe@kailand.kai.com Newsgroups: comp.sources.bugs Subject: Perl V3 side effect Message-ID: <2800019@kailand> Date: 24 Oct 89 00:37:04 GMT Lines: 52 Nf-ID: #N:kailand:2800019:000:2039 Nf-From: kailand.kai.com!pwolfe Oct 23 15:29:00 1989 One side effect of Perl Version 3.0 that broke a number of our scripts has to do with the normal filehandle names being changed from lowercase to uppercase (eg. from stdout to STDOUT), which changed the default detail line format name, so scripts that depended on that name being "stdout" now produce NO output at all. I can't say that this is actually a bug, but it was an unexpected change, and will delay installation of version 3 on a number of our machines (until all broken scripts can be found and fixed). The fix is to assign an detail record format name ($~ = "stdout";). While you're at it, you might as well assign the header format name too, just in case that changes sometime in the future. The enclosed example prints out the contents of the system password file (in the old manner, since I haven't gotten the new "getpwent()" routine to work yet). Near the bottom, I have a format line to define the detail line for the default standard output channel. With version 2, the default output filehandle is "stdout", so "format stdout =" works, and "format STDOUT =" doesn't. With version 3, the default output filehandle is "STDOUT", so the opposite is true. I have sent email to Larry Wall about this. Patrick Wolfe (pat@kai.com, kailand!pat) System Manager, Kuck & Associates, Inc. > #!/usr/bin/perl > > # uncomment these to allow this script to work under Perl V3 > #$^ = "top"; > #$~ = "stdout"; > > open (passwd, "/etc/passwd") || die "cannot open passwd file for input, stopped"; > > while () { > chop; > ($name, $passwd, $uid, $gid, $gcos, $dir, $shell) = split (/:/); > write; > } > close (passwd); > exit (0); > > format top = > Passwd File > Login Uid Gid Shell Home > ------------------------------------------------------------------------------- > . > > format stdout = > @<<<<<<< @>> @>> @<<<<<<<<<<<<<<<<<<<<<<< @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< > $name $uid $gid $shell $dir > .