Re: [Nolug] Crappy Perl Code

From: Ron Johnson <ron.l.johnson_at_cox.net>
Date: 13 Jul 2003 23:30:08 -0500
Message-Id: <1058157008.19798.57.camel@haggis>

On Sun, 2003-07-13 at 00:56, Mark A. Hershberger wrote:
> Alex McKenzie <alex@boxchain.com> writes:
[snip]
> For _, see perlfunc(1):
>
> If any of the file tests (or either the ""stat"" or ""lstat""
> operators) are given the special filehandle consisting of a
> solitary underline, then the stat structure of the previous file
> test (or stat operator) is used, saving a system call. (This

Is it just me, or does this sound to others like this is a bug
waiting to happen? Of course, if I'm misinterpreting it, please
correct me.

For example:
  stat $file1
  <blah>
  <if, while, function call, etc>
  <blah>
  stat _

Then a maintainer comes in and adds "stat $file2":
  stat $file1
  <blah>
  stat $file2
  <if, while, function call, etc>
  <blah>
  stat _

Thus, the "stat _" will operate on $file2 instead of the desired
$file1. If this is done in a long, complicated program originally
written by a "clever but not good" programmer, it may take a long
time analyzing the program just to make sure a small change does
not introduce a possibly serious bug.

-- 
+-----------------------------------------------------------+
| Ron Johnson, Jr.     Home: ron.l.johnson@cox.net          |
| Jefferson, LA  USA   http://members.cox.net/ron.l.johnson |
|                                                           |
| 4 degrees from Vladimir Putin
+-----------------------------------------------------------+
___________________
Nolug mailing list
nolug@nolug.org
Received on 07/13/03

This archive was generated by hypermail 2.2.0 : 12/19/08 EST