Perl for the Aspiring Hacker - Part 1 - Variables
Before I start a series on remote exploitation, I think we should learn the basics of Perl. Perl, Ruby, C, C++, Cython and more are languages that some penetration testers just need to learn. Perl is a great language for multiple things, sadly, like many other scripting languages, it is limited by the environment in which it is designed to work in.
In this tutorial, we'll be going over the basics of Perl.
As you may know, most Perl scripts start with the hello world:
print "Hello world!\n";
You may see lots of scripts start with the "!#/usr/bin/perl", this is known as the 'Shebang'.
You may see the line ends with a semicolon. In Perl, almost every line ends with a semicolon although some of them don't need to, but usually, you're better of putting the semicolon anyways.
Perl, obviously has a lot of data structures, the most common of them being the scalar variable. Variables in Perl are always addressed with a $.
print "Hello! My name is Ax0n. What is yours?\n";
$name = <STDIN>;
print "$name is a pretty rad name, bro.\n";
In that script, we didn't just use a variable, we used a couple of things. Let's walk through them. We have the shebang in the first line, as usual. On the second line we give out a proper introduction. The next line defines our variable '$name' and awaits input from <STDIN>. What chomp does it gets rid of the statement. You can use chomp or chop.
That is all for today!