It's not necessary to go all the way to a separate package; you can get away with wrapping the functions in subs and then modifying your main-line code to call them. You can then add a way to run a test vs. doing a backup via Getopt::Long or an environment variable. (Personally I'd spend the time to create the package simply because I could leverage Perl's build-and-test infrastructures.)
On a cursory scan, I think this
doesn't do what you think it does. If you qx() the string in $dir then it will be executed, but just referencing it like this, Perl will only check it to see if it's "true" (i.e., not null in this case), and will not execute it!$dir or die "Can't mkdir $dir: $!";
The while loop may work, but honestly, you need to test it to be sure that it does.
A couple other notes: what happens if one of your files is bigger than a DVD? (Right now you'll attempt to mv it and fail.)
If the subroutine wrapping seems like too much work, then you should at least create some sample directories to be backed up, figure out by inspection what should happen, and then run the script to see if it does. If you change the size of a DVD to (say) 500 bytes, you can create a few files of a couple hundred bytes each and try it out.
EDIT: typos.
In reply to Re: BinPack Algorithm Use To Pack Files In a DVD
by pemungkah
in thread BinPack Algorithm Use To Pack Files In a DVD
by mgrangeiro
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |