Cookie Notice

As far as I know, and as far as I remember, nothing in this page does anything with Cookies.


Stupid Things with References

It took me a while to figure out why I was writing junk to the DB. More or less, this is my code.

my $request = get_request( $request_id ) ;
my $to_wiki = $request ;

I thought to be making a copy of the hash in the hashref.

I meant to be making a copy of the hash in the hashref.

I wasn't making a copy of the hash in the hashref. I was making a copy of the hashref address. Which means every change I made to $to_wiki, I made to $request.

Instead, I needed to do something more like this.

my $request = get_request( $request_id ) ;
my $to_wiki ;
%$to_wiki = map { $_ => $request->{ $_ } } keys %$request ;

I present this as a cautionary tale. Please, learn from the mistakes of others.


Ghosts of Coding Sessions Past

Boss wants to be able to clone a request, to take an item on our list and reset it.

Fair enough, but ...

Requests are among the first things I coded at the lab. Before that, I was at the clinic, and while I did a fair amount of coding there, I was much more of an admin than a developer there, and I have learned a lot about developing here.

Thing is, I learned most of it after I wrote he request code.

A request has lots of data about it. A name, an ID number, who requested it and how to get in contact, what they want done with it, etc. Each request has a number of samples, and the samples have names and numbers and amounts and such. Each sample can have a barcode, which I won't explain. Each request can also have 0-whatever statuses. I back-end to MySQL, and I can copy and massage data, and say in the status that request j is a clone of request i. All that is cool.

Then there's the Wiki.

About everything on the web page is also on the Wiki. It serves as the lab notebook, and I create the stubs. Yes, there's synchronization problems between the Wiki and the database. I try not to think about it, because I cannot find a way for the structured data to interact with the unstructured in a good way.

So, I dread the Wiki stub creation code. I coded it in Perl, using the CGI module. Before I came to the lab, I hand-coded my HTML in my Perl, like my $val = "<div> $foo </div>" which isn't good either, but 200 lines of code like $val = $cgi->div( $foo ) isn't doing my mind any good.

Thrown into the mix, we're moving from our old server to virtual server Sidam, which is Midas spelled backwards, as everything it touches turns to sh*t. I should be moving my code to that server, but that looks to be a bigger issue. To make sure that things finish, we want to move the code as close to as-is as possible. Because it's broken by design (see above) I want to use this opportunity to make great, sweeping changes.

I think I'll implement this with Template Toolkit and suck up the technical debt, but I don't look forward to that process.