index is a bare word, it should probably be $index. In addition, it has not be properly initialized, it is undefined at this point in the code. The substr function probably needs two or three arguments (check the documentation). And, anyhow, the substr function is not adapted to your problem, since you do not know how long the first field (first name, middle name, last name) will be. You probably need to split your input line on the separator (/).

Code

my $first = substr my $middle = substr my $last = substr

This obviously will not compile, as the syntax for the substr is not respected and the semi-colons are missing.

Code

my $id = lc() . lc() . lc();

The lc function needs an argument.

Code

while(<IN>) { my $passwd = <STDIN>; my $line = $_;

It is probably better to obtain the password from the user before starting the while loop on the file. Something like this: