sjh - mountain biking running linux vegan geek spice - mtb / vegan / running / linux / canberra / cycling / etc

Steven Hanley hackergotchi picture Steven
Hanley

About

email: sjh@svana.org

web: https://svana.org/sjh
twitter: https://twitter.com/sjhmtb
instagram: https://instagram.com/sjhmtb

Other online diaries:

Aaron Broughton,
Andrew Pollock,
Anthony Towns,
Chris Yeoh,
Martijn van Oosterhout,
Michael Davies,
Michael Still,
Tony Breeds,

Links:

Linux Weekly News,
XKCD,
Girl Genius,
Planet Linux Australia,
Bilbys,
CORC,

Canberra Weather: forecast, radar.

Subscribe: rss, rss2.0, atom

April
Mon Tue Wed Thu Fri Sat Sun
   
21
     

2009
Months
Apr

Categories:

Archive by month:

Tue, 21 Apr 2009

Another change to cache_timestamps for perl 5.10 - 11:28
Upgrading this server to lenny I finally have perl 5.10 on the system, this caused a problem with my blosxom plugin cache_timestamps. Using File::Find I previously had a sub routine wanted defined inside a scope with some variables available in that scope. However on upgrading to 5.10 this no longer worked.

It used to be something like this

{
   my (%h1,%h2);
   sub wanted {
      $h1{$File::Find::name} = "someval";
   }
   find (&wanted, "topdir");
}

However when I changed to perl 5.10 though the assignment seemed to work (blosxom runs without -w or use strict enabled) if I tried to display %h1 inside wanted or tried to use it like a hash I got a weird error "Bizarre copy of HASH in refgen" at the line of code I tried to use the variable as a hash. Looking at other uses of File::Find it seems everyone used anonymous subroutines from the call to find. I have changed the code to do the following.

{
   my (%h1,%h2);
   find (sub {
      $h1{$File::Find::name} = "someval";
   }, "topdir");
}

And now the hashes are in scope and not some so called Bizarre copy any more. The code for the cache_timestamps plugin can be found here and details about cache_timestamps are in my comp/blosxom category.

Update: found some details, rather than searching for the error message I started searching for variable scope changes in 5.10. Found this page talking about state variables being available in 5.10 as my variables are not persistent across scope changes.

[/comp/blosxom] link


home, email, rss, rss2.0, atom