Actually I am just a student, and this is a task assigned to me from my tutor. Since he didn't give us any materials on learning perl, I have to learn all fundamentals from web by myself. I know the algorithm of this snippet is awful easy but I was just stuck on it b'cause I know little about Perl. Anyway, thank you guys for help,really appreciate!