Header Banner
Null Byte Logo
Null Byte
wonderhowto.mark.png
Cyber Weapons Lab Forum Metasploit Basics Facebook Hacks Password Cracking Top Wi-Fi Adapters Wi-Fi Hacking Linux Basics Mr. Robot Hacks Hack Like a Pro Forensics Recon Social Engineering Networking Basics Antivirus Evasion Spy Tactics MitM Advice from a Hacker

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:

#!/usr/bin/perl

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.

Variables

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 $.

Example:

#!/usr/bin/perl

print "Hello! My name is Ax0n. What is yours?\n";

$name = <STDIN>;

chomp $name;

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!

You already know how to use your phone. With Gadget Hacks' newsletter, we'll show you how to master it. Each week, we explore features, hidden tools, and advanced settings that give you more control over iOS and Android than most users even know exists.

Sign up for Gadget Hacks Weekly and start unlocking your phone's full potential.

Related Articles

Comments

No Comments Exist

Be the first, drop a comment!