Satya's blog - 2004/05/

May 31 2004 19:49 Array refs in perl
Using HTML::Template, I was trying to put an array inside a loop onto another array... nothing like code snippets:
while(stuff) {
# more stuff
push @arr2, {K1 => \@arr1, K2 => $otherstuff};
}
People will recognize that an anonymous hash with keys K1 and K2 is being pushed onto arr2.

At a certain point in the loop, given certain conditions, @arr1 needs to be blanked and emptied. But I wans't getting the right results. Data::Dumper showed that the next iteration pointed back at the first instance of arr1. No, "instance" is the wrong word. The array pointer was still the same, so by assigning the pointer (a.k.a. reference) to K1 I was clobbering whatever happened to be in @arr1 before I blanked it, in the next iteration after blanking.

So here's the fix:
while(stuff) {
# more stuff
push @arr2, {K1 => [ @arr1] , K2 => $otherstuff};
}
That creates an anonymous array which is assigned as the value for K1, and that anon array's contents come from @arr1. Problem solved.

Tag: tech perl

May 23 2004 00:00 Drove back from Florida today
I just drove back from Florida, and boy are my arms tired!

Doesn't work that well, does it. But my arms *are* tired from the driving.

Tag: self silly travel

May 15 2004 18:43 Lynx gets it right
Using the Lynx browser, go to a URL like http://username@www.google.com/ . Lynx shows a short status bar alert (3 seconds long by default, if I remember the Lynx defaults) saying something like "Alert! URL contains username".

This is to prevent an attack of this nature:
http://securesitelikeebay@trojansite/steal.your.data

Tag: tech

May 06 2004 18:06 Names given to computers
http://c2.com/cgi/wiki?NamesGivenToComputers I contributed bfs, code, red, mike, ike, kickin, chicken.

Tag: link tech

May 04 2004 17:56 Getting to the DMV
I got directions to the DMV in Upchuck, saying take 26W, 216B, left on Azalea, left on Leeds. To get on 26, there was some delay so I broke right for MountP and then got lost in I'on. ("Lost" here means I knew where I was but not how to get to wherever I wanted to go without retracing.)

Finally hit the 526, got on the 26 coming back, and took exit 216A because I was going in the opposite direction. After blundering up Sam Ritt, turned around somehow and passed under 26...

To see that my left on Azalea was in the next lane over. Turned around a bit looking for Azalea/Leeds, found 26, got on, took exit 216B this time, couldn't merge, got back on 26 (it's a near-perfect cloverleaf intersection), took the next exit (216A? by this time I was down to dead reckoning), possibly going the wrong way on Cosgrove again, got back on 26, took the next exit again (216B, I'm pretty sure), merged, switched, and got on Azalea.

Whee.

Tag: exp