Array (perl) Part 5

#print qw (‘one’,’two’,’three’)

print ((‘salt’, ‘vinegar’, ‘mustard’, ‘pepper’)[2]);
print(“\n \n”);
#array dalam sebuah perl sama saja seperti bahasa pemograman lain

#ARRAY 1 DIMENSI
my $bulan = -3;
print qw(
January february maret
April mei juny
July agustus september
October november december
)[$bulan];
print(“\n \n”);
# bahwa sebuah array di atas merupakan
# 0 1 2
# 3 4 5
# 6 7 8
# 9 10 11

#ARRAY MULTI DIMENSI

my $mone=1; my $mtwo=3;
#($mone, $mtwo) = (1, 3);
print ((“heads “, “shoulders “, “knees “, “toes “)[$mone, $mtwo]);
print “\n \n”;

#ranges(batasan)
print “Counting up: “, (1 .. 6), “\n”;
print “Counting down: “,reverse (6 .. 1), “\n”;
print “Counting down (properly this time) : “, reverse(1 .. 6), “\n”;
print “Half the alphabet: “, (‘a’ .. ‘m’), “\n”;
print “The other half (backwards): “, reverse(‘n’ .. ‘z’), “\n”;
print “Going from 3 to z: “, (3 .. ‘z’), “\n”;
print “Going from z to 3: “, (‘z’ .. 3), “\n \n”;

my @days;
@days = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday);
$days = 31;

my @array1;
my $scalar1;
@array1 = qw(Monday Tuesday Wednesday Thursday Friday Saturday Sunday);
$scalar1 = @array1;
print “Array 1 is @array1\nScalar 1 is $scalar1\n”;
my @array2;
my $scalar2;
@array2 = qw(Winter Spring Summer Autumn);
$scalar2 = @array2;
print “Array 2 is @array2\nScalar 2 is $scalar2\n”;

Download Project nya di Sini

Advertisements

Published by

jarcode

hello I am jarcode

3 thoughts on “Array (perl) Part 5”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s