Friday, September 25, 2015

Array's Perl Program

Script:

@numbers = (1,2,3,4,5);
print "@numbers \n";
print "$numbers[2]\n";

@words = ("one", "two", "three");
print "@words \n";
print "$words[2]\n";

$words[3] = "four";
print "@words \n";

$total = $#words;
print "$total\n";

Output:
1 2 3 4 5
3
one two three
three
one two three four
3

********************************************
Script:
@array = qw ( one two three four);
print "@array \n";

@num = (1..8);
print "@num \n";

@array1 = (1) x 100;

print "@array1 \n";

Output:
one two three four
1 2 3 4 5 6 7 8
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1

1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1


No comments:

Post a Comment