in reply to Task scheduling using perl

I sure hope that's not really your data. Task1 depends on Task3 and Task3 depends on Task1. your program should probably check for such loops.