#!/bin/perl -w
my @people = ();
print "We've got empty array here\n";
push(@people, "Howard");
print "Pushing Array";
print "the array \@people is now with: @people in it\n";
print "let's append another few ppl into it\n";
push(@people, ("Kevin","David","Hetfield"));
print "our \@peple array is now: @people\n";
print "Now we'll shift Howard from our massive";
my $got_ticket = shift(@people);
print "Now \$got_ticket is: $got_ticket\n";
print ("And the left ppl without a tickets are: \@people = @people\n");
print "Hetfield's got a ticket now\n";
$got_snd_ticket = pop(@people);
print "Ppl without a ticket left are: @people\n";
print "We'll now find out how many ppl without a ticket are left\n";
my $ppl_without_a_ticket = scalar(@people);
print "Ppl without a tickets are: $ppl_without_a_ticket\n";
print "The last person on the queue is $people[$#people]\n";
print "And the first one is $people[0]\n\n";
print "Now let's define an array and test some perl looping\n";
my @arr = ("cyan","magenta","yellow","black");
print "Our \@arr got the: \"@arr\" elements in it\n";
print "We\'ll now loop through the \@arr\n";
my $f = 0;
my $loop_count = scalar(@people);
print "\$loop_count: $loop_count\n";
foreach my $i (0..$loop_count) {
$f++;
print "loop num: $f = $arr[$i]\n";
}
print "\n\n","Now we'll demonstrate finding an item into our array \@arr\n";
print "We'll search for Mitnick into: @arr\n";
my @result_arr = grep(/Mitnick/,@arr);
print "Here is the new created \@result_arr:@result_arr\n";
print "Guess it is empty this means no word \"Mitnick\" inside :]\n";
print "I'll now write a little program for inputting data into array\n";
print "And then searching for a specific string into it\n\n", "Here we go now\n";
print ("Enter record count:");
my $record_count = <STDIN>;
chomp($record_count);
print ("Okay Enter 'em now:\n");
my @data_array;
for ($i=0;$i<$record_count;$i++) {
$data_array[$i] = <STDIN>;
chomp($data_array[$i]);
printf "Record in.\n";
}
printf ("After the data input we\'ve got this array");
printf ("\t@data_array\n\n");

printf ("Now enter the search string:");
my $search_string = <STDIN>;
chomp ($search_string);
my $search_result = grep(/$search_string/,@data_array);
#print ("Searh Result: $search_result");
if($search_result eq 0) {
print ("The string: \"$search_string\" was not found into the \"@data_array\"\n");
}
else
{
print ("String: \"$search_string\" match in \"@data_array\"\n");
}

printf ("Okay now a little more exersisises*\n\n\n");
printf ("We\'ll now demonstrate array slicing");
my @arrayy = ("Evil","Fucking","Satan","Die","You","MTF","Shit");
my @slice = @arrayy[1..2];
print "\n Here is the slice: @slice\n";

print "\n Next excersise is reversing array\n\n";
print "This is the array: @arrayy\n\n";
sleep(2);
my @array1 = reverse(@arrayy);
print ("Here it is in a reversed form: @array1\n\n");
sleep(3);


