Main Content

Admission

Archive - Originally posted on "The Horse's Mouth" - 2009-11-19 06:02:28 - Graham Ellis

opendir(DH,".");
 
for $sd (readdir DH) {
   next if ($sd !~ /\./);
   next if ($sd !~ /[a-z]/);
   print "$sd backup ...\n";
   `tar czf 20091119/20091119_$sd.tgz $sd`;
   }


I admit it ... when it comes to the "crunch" and I need a quick script to do some systems admin work, it still has to be Perl!

The script above is currently running, via another window, on one of our two dedicated servers. "It's a very old machine - you should upgrade it" said their technician as he did a hard reboot for us yesterday; hmmm - it's not *that* old, but having heard a comment like that I think I'll ensure we have a fresh mirror of each virtual host ...

Learn how to write perl PROPERLY - i.e. commented, nicely structured, maintainable, without constants hard coded ... on our Perl Programming course. That will also equip you to write 'nasty' little scripts like the one above when you have the need!