[]
[]
This is a homwork assignment, please don't ask us to debug your entire program.
Pleas etell us where you are stuck, or what goes wrong when you compile and/or run your program.
A couple of advice.
Put the following lines near the top of each of your Perl programs:
Perl Code:use strict; use warnings;
They will help you considerably finding errors or faulty constructs.
Don't call function with this obsolete syntax:
Rather use:Code:&task_number2;
Also, please the code tags for your code, this makes your code more readable and prevents your regex:Code:task_number2 ();
if($x=~m/(\d+)\d+)
\d+)
\d+)
\d+)(\d+)
\d+)
\d+)/)
from looking really sad.
Last edited by Laurent_R; May 25th, 2013 at 10:55 AM.
Whenever I see args such as -n, -t, -v etc I would use the Getopt::Long module to handle the parsing of the args rather than manually parse @ARGV.
Additionally, I'd write a separate subroutine to handle each of the actions and use a dispatch table to determine which sub to execute. The subroutine names should give an indication of what they do. Names such as "task_number2" and "task_number4" are very poor choices.
Since you're being given exact widths for each field of the lines in the source file, that tells us that you have a fixed width file format and normally the best way to parse/extract those fields is to use the unpack function instead of a regex. If required, you can apply validation tests on some or all of the fields after using unpack.