Excellent. ++. I had this idea but was unsure as to implementation.
P.S. There is a slight code bug. You test in GetLastNumber for a file of the format "sample_<number>.pl", but you create a file of the for "sample_<number>".
Brain fart issue, I suppose. :)