$line=~/(\w+),(\w+),(\d+),(\d+),(\d+)/;
And what happens when the regex doesn't match? don't use $1, $2, ... withouth checking that.
An alternative appraoch:
my ($firstname, $lastname, @marks) = split m/,/, $line;
This has the advantage that you can have an arbitrary number of marks. Of course you'll need to adjust the rest of the code a bit, for example;
$totalmarks = 0; $totalmarks += $_ for (@marks);
foreach $mark(@marks){ $status=checkpass($mark); }
So $status is the status of the last mark only. Is that what you want?
You should test your script also with data of failing students.
BTW I strongly recommend to align the code better, one tab for each opening brace.
In reply to Re: Students Rank calculation for the below perl script
by moritz
in thread Students Rank calculation for the below perl script
by valavanp
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |