revjim.net

June 11th, 2002:

geeks only

Apparently, this Perl code does something I didn’t realize:

foreach my $thevalue (@some_array) {
	# Do something
}

In this case $thevalue is actually a reference to that index of @some_array. I’m not sure how, in all of the Perl I’ve written, I would have never run into that, and I haven’t looked it up in any documentation, but that seems to be the case. Actually… even in this case, I wouldn’t have run into it except I was helping someone else. To see proof of this (or to see my proof, for you to disprove) look at this code:

my @some_array = ('A123456', 'B123456', 'C123456');

my $cnt = 0;
while($cnt < 2) {

	foreach my $thevalue (@some_array) {
		chop($thevalue);
		print $cnt . ": " . $thevalue . "\n";
	}

	$cnt++;

}

Code untested.

You would think it would print this:

0: A12345
0: B12345
0: C12345
1: A12345
1: B12345
1: C12345

But it doesn't, it prints:

0: A12345
0: B12345
0: C12345
1: A1234
1: B1234
1: C1234

Weird. I don't think it should work that way at all.

untitled

So my boss isn’t a total idiot.

My VPN access is down because my SecureID started reading “Prog” and I haven’t got a new one yet. A service that always goes down (because the server has major issues and we are migrating everything off of it) did so again this morning. All of my employees are on the road, so none of them can get to a computer and, like I said, I don’t have access from here.

I walked my boss through logging into the server, becomming root, reading log files, starting MySQL, killing Apache manually, and restarting. He did everything I asked him on the first shot without messing up, or mistyping, or not understanding the symbols I was telling him to type. I am kind of proud.