Login Register


[TUT] Perl Login script | If / Else [Beginner LVL 3] filter_list
Author
Message
[TUT] Perl Login script | If / Else [Beginner LVL 3] #1
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:
\n
just means, newline.

Code:
print"\n\n----# Login #----\n"; print"\nUsername: ";

All this does is prints the text in the Quotation marks.

Code:
my $input = "Root";
this just sets the variable that, 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.
[Image: 6caf54.gif]

Reply







Users browsing this thread: 1 Guest(s)