I have index.pl and subs.pl. When I run the program, the user inserts the date of birth and then it is passed to the getage()
subroutine in subs.pl, which has many subroutines.
getage()
than implicitly calls another subroutine called validate()
which validates the date entered by user.
When I run the index.pl and the user enters the date as 03-04-2005
, the following error comes out:
can't modify non-lvalue subroutine call at subs.pl line 85, <> line 1
At 85th line of subs.pl I have:
list(my $val,my @value) = validate($dob);
validate()
returns a message and the date($dob)
which is sent from getage()
.
Some code from validate():
sub validate
{
my $dob = shift;
my $error;
my @test;
@test = split("-",$dob);
if (!@test)
{
$error = "date separator should be - ";
return ($error,@test);
}...