Introduction: Learn Perl Easy to Medium

Perl is a text based scripting languge that has it's advantages and disadvantages,this tutorial will give you an overview of the basics and the functions that most scripters (AKA;programers)
would use. LETS GET STARTED! (for windows operators only)
I am assuming that you have worked with a hello world program before or/and worked with a interpeter.

when scripting in perl you have to change your PATH,
but if you dont want to do this, use perl express (shown below).

*note plese rate and comment this instructable

Step 1: The Materials

1.a perl interpeter (google it!)
2.if you want, perl express (google it!)
3.also, if you want , modules (google perl modules for some)
install the modules in the "lib" folder in your perl interpeter's directory

Step 2: Your First Program

okay lets make a simple program,
copy and paste this #!/usr/bin/perl
print "hello world";
that is the simplest program you can make, if you want to add to it a little, type #!/usr/bin/perl
print "hello \n world";
you made your first program! , \n is to make a new line
now lets get a little more advanced

Step 3: Variables

now there are three types of variables,
1.scalers (holds one strip of data) (( $scaler name = value;)
2.arrays (holds multiple strips of data)
((@array name = (values);)
3.hashes %hashname = (value => other value , value => other value #put as many of theses as you want )

Step 4: Getting More Advanced

lets make scripts that print the values of variables,
type these scripts! (you dont have to type the comments , comments are noted with a #)

1. #!/usr/bin/perl
$variablename = 5;
print "$variablename";

2. #!/usr/bin/perl
@arrayname =(value , value2);
#remember , you must refer to arrays as scalars example (the indexe are in order starting at zero

print "$arrayname{0}\n"; #print value
print "$arrayname{1}\n"; #print value2
note:for the code above the { and the } symbols are actully square brackets
3. #!/usr/bin/perl
my %hash = ( v => value , v2 => value2);
print $hash{v};

now lets learn another use for scalers,
type or copy and paste this code

#!/usr/bin/perl
$scalername = <STDIN>;
print $scalername;

type in anything you want
when using command prompt but if you're using perl express,
click on std.input then click on the i/o symbol

now lets find some more uses for variables

Step 5: Another Use and Looping

copy and paste this code

#!/usr/bin/perl
$scalername = <STDIN>;
if ($scalername =~ m/bill clinton/)
{
print "its clinton alright!";
}

okay, you might be asking "what does the if do?"
scroll down and you will see!
>
>
>>
>
>
>>
in the if statment perl behaves the following way,perl asks "does $scalername contain bill clinton?"

here is another function that is also useful

the while function example:
copy and paste this code
#!/usr/bin/perl
$a = 1;
while ($a==1) # == is for numbers only
{
print "a = 1";
}
else { print "a does not equal 1"; }

the next step will talk about boolean functions

Step 6: Boolean

boolean is for numbers only!
heres some functions

== , equals
!= , not equal
< , greater than
> , less than
(*) , multiply note:in multiply theres no ()'s
+ , add

Step 7: Putting It Together

copy and paste this code ,

#!/usr/bin/perl
$operation = <STDIN>;
if ($operation =~ m/multiply/)
{
print "enter a number:\n";
$a = <STDIN>;
print "enter a number to multiply $a:\n";
$b = <STDIN>;
$c = $a * $b;
print "$a multiplyed by $b = $c\n";
}
if ($operation =~ m/add/)
{
print "enter a number:\n";
$a = <STDIN>;
print "enter a number to add to $a:\n";
$b = <STDIN>;
$c = $a + $b;
print "$a added to $b = $c\n";
}

Step 8: Finished!

when you write your own programs you might want to add this function in your code

use warnings;










okay youre done!