#!/usr/bin/perl
use strict;
my $name;
my $address;
# next and last
# next will take you to the next iteration of the loop
# last will jump out of the loop
while(1<2)
{
print "Please enter your name: ";
chomp($name=);
next if ($name eq "stop"); # could say last if ($name eq "stop")
print "Enter address ";
chomp($address=);
print "$name\n";
print "$address\n";
}
print "I left the loop\n";
# Lists and Arrays
my @array1=(10,20,30);
my @array2=("bill" , "joe" , "sue");
my @array3=("bill", @array2, "joe","bill",@array1,"sue");
print "@array3";
(0,1,2,3,4,5,6,7,8);
(0..8);
my $first=10;
my $last=12;
my @ar=($first..$last, 12,56,"bill",12..18,'a'..'f');
print "TEST **** @ar\n";
my $a="joe";
my $b="sue";
my @array5=(34,56,$a,$b);
print "BEfore pop array is @array5\n";
my $pop_value=pop(@array5);
print "after pop value is $pop_value and array is @array5\n";
# undef and defined
my @data=(10,20,30);
my $x1=shift(@data);
my $x2=shift(@data);
my $x3=shift(@data);
my $x4=shift(@data);
print "x1 is $x1 x2 is $x2 x3 is $x3 x4 is $x4\n";
if (defined($x4))
{
print "x4 has a value\n";
}
else
{
print "x4 doesnt have a value\n";
}
my @big_array;
$big_array[4]=45;
$big_array[12]="bill";