|Do you know where your variables are?|
Pure Perl or the toolkit?by Abigail-II (Bishop)
|on Aug 20, 2003 at 14:15 UTC||Need Help??|
Every now and then, there is a discussion whether to shell out to do something, or do it all in Perl. Many purists argue that if it's possible to do it in Perl, you should do it in Perl. Portability and such. And specially if the functionality comes in a standard module.
I got bitten by that today. I was working on a few programs that, in combination with make create a floppy disk to install a small Linux system on a specialized box. Part of the process involves copying executables to the root file system to be. Simple, isn't? Just do
Well, that was what I did. Later, I needed to copy a directory structure. According to the manual page of File::Copy, that module just deals with copying files, so I shelled out:
But back to File::Copy and copy. The floppy disk was created, I insert it in the box, reboot, and after some time, it fails. /sbin/loader is not executable.
It turns out that File::Copy doesn't respect execution bits. Urg. Out went File::Copy and back came shelling out to the UNIX toolkit.
Here's a program that shows the unwanted behaviour of File::Copy: