mini-CPAN on Windows

barbie on 2002-10-08T16:16:01

I had a play with Randal's script for creating a mini-cpan yesterday, [click here]. Unfortunately after creating the appropriate directories, and updating the script, I ran said script and joyfully watched as all these archives were successfully loaded into my mini-cpan. Then I watched in horror, when after over 2 hours later every single entry got deleted. Surely Randal couldn't have made such a silly mistake as to allow everything to be deleted?

Alas Randal had only tested on a UNIX box. Due to the inconsistent way File::Spec and Find::Find handle file paths on other operating systems, the whole script broke :(

I was going to see if I could write a patch, but after wading through the 2 modules, I felt it was far safer to amend the script. So if you want to run the script on a Windows box, add the following line between lines 69 and 70 in Randal's script:

$local_file =~ s|\\|/|g;

The moral of this story is be very careful if you're relying on portability when using File::Spec and Find::Find output together.

Update: fixed the regex.


"o" for a variable

Matts on 2002-10-08T16:58:56

I've seen /o used without variables before and it always looks odd to me, and I make sure I question the developer about it so that we both have a better understanding of why it ended up there. Was it just a "knee jerk" reaction - i.e. something you just always add to regexps because you once read it made them faster? Or was it an artifact of old code that is now removed? Or just a lack of understanding of what /o does? Or an honest mistake as you hurriedly made the code work?

Either way, /o isn't required here. It does nothing (except make me post this) in this case. I have no problem with you having it there, I just thought you'd like to know.

Re:"o" for a variable

barbie on 2002-10-08T18:10:56

My misunderstanding. I didn't realise that it should just be use when variables are involved. I had wrongly assumed it should be applied to anything that should be compiled once.

Something else I can now add to my beginner's guide to regexes ;)

Thanks Matt.