Category Archives: Files and Filehandles

Copy instead of renaming to preserve hard links

Yesterday I posted about not overwriting a file until you knew you had completely and correctly stored its data. Part of that was about data security and another part was completeness for other consumers. I used a temporary file and rename to move the new file into place. That’s not the entire story though.

Use a temporary file instead of clobbering data

How do you replace the the contents of a file? This is something I’ve been thinking quite a bit about because we often get away with bad practices, and it’s completely within the scope of Learning Perl to know how to do this. It might make a good edition to the next edition of the […]

Ruling the world with Perl and Excel

In Chapter 12 of Learning Perl, we have an exercise for people to practice using the file test operators. Our answer, which can only use the stuff we’ve covered in the book to that point, is simple:

Why we teach bareword filehandles

There’s a debate raging in Perl 5 Porters over some updates to perlopentut. Mike Doherty sent a patch to remove the bareword filehandles, stepping into the overlapping minefields of fashionable practice and documentation authorship. That second one is beyond the scope of Learning Perl, so I’ll ignore it even though that’s almost the entire debate. […]