You test it by running it! First, turn it into a proper Perl script with a shebang line. The shebang isn't really required, but can be useful so that you can run the script without having to type "perl" first.
#!/usr/bin/perl -w
print "What is your last name? ";
$lastname = <STDIN>;
print "What is your first name? ";
$firstname = <STDIN>;
print "Please enter three single digits numbers separated by commas. ";
@numbers= <STDIN>;
print "You entered '@numbers'.";
$firstinitial=index("$firstname", 0, 1);
print "Your user name is '$lastname$firstinitial'. ";
print "Your password is ('@numbers', 2, 1, 0)";
save it is input.pl or something similar.
You can run it by typing "perl input.pl". If you want to get fancy, you can do
chmod +x input.pl
and then run it by just typing "input.pl".
Still, it isn't going to work properly due to:
@numbers= <STDIN>;
When you read from standard input in list context, you read until end-of-file. First, read it into scalar like:
$numbers=<STDIN>;
Then, split it into an array like so:
@numbers=split /,/, $numbers;
Also, don't forget to "use strict" and "chomp" your input. Here is the final version:
#!/usr/bin/perl -w
use strict;
print "What is your last name? ";
my $lastname = <STDIN>;
chomp $lastname;
print "What is your first name? ";
my $firstname = <STDIN>;
chomp $firstname;
print "Please enter three single digits numbers separated by commas. ";
my $numbers= <STDIN>;
chomp $numbers;
my @numbers = split /,/, $numbers;
print "You entered '@numbers'.";
my $firstinitial=index("$firstname", 0, 1);
print "Your user name is '$lastname$firstinitial'. ";
print "Your password is ('@numbers', 2, 1, 0)";