Other posters have already provided fine solutions so I won't go there but, in general, your code should always include:
use strict; use warnings; use diagnostics; # not strictly necessary but really nice
The other posters did hint at that but I wanted to be more explicit.
Also, in the future it would be especially cool if you would clearly flag homework in the header line.
Hope this helps!
(update: minor clarification mod)In reply to Re: Parsing a text file
by wade
in thread Parsing a text file
by nimajneb
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |