![]() |
|
[TUT] Perl Login script | If / Else [Beginner LVL 3] - Printable Version +- Sinisterly (https://sinister.ly) +-- Forum: Coding (https://sinister.ly/Forum-Coding) +--- Forum: Coding (https://sinister.ly/Forum-Coding--71) +--- Thread: [TUT] Perl Login script | If / Else [Beginner LVL 3] (/Thread-TUT-Perl-Login-script-If-Else-Beginner-LVL-3) |
[TUT] Perl Login script | If / Else [Beginner LVL 3] - FrostByte_mybb_import5923 - 05-10-2011 hey and welcome to my perl login script. This is a very simple look at perl and user logins but does use the if else statements well, hope you enjoy. so here is the over all code. Code: print"\n\n----# Login #----\n";
print"\nUsername: ";
my $input = "Root";
my $user = <STDIN>;
if ($user eq $input) {
print"Welcome...";
}
else {
print"Access denied tracing IP";
}Explanation. Code: \nCode: print"\n\n----# Login #----\n";
print"\nUsername: ";All this does is prints the text in the Quotation marks. Code: my $input = "Root";Code: my $user = <STDIN>;now this is slightly more complex, "my $user" is the Variable and "<STDIN>" simply stands for Standard input. This is where the text is entered. Code: if ($user eq $input) {
print"Welcome...";
}
else {
print"Access denied tracing IP";
}now the If Else statement, this just says that IF $user (the Variable / input text) = "Root" / $input. then it print's the text "Welcome..." else it print's the text "Access denied tracing IP". very simple very easy to understand. Hope you enjoyed this Perl Tutorial. |