• Tidak ada hasil yang ditemukan

Associative Arrays

N/A
N/A
Protected

Academic year: 2024

Membagikan "Associative Arrays"

Copied!
2
0
0

Teks penuh

(1)

1

Kingdom of Saudi Arabia ةيدوعسلا ةيبرعلا ةكلمملا Ministry of Education ميلعتلا ةرازو

Umm AlQura University ىرقلا مأ ةعماج

Adham University College مضأب ةيعماجلا ةيلكلا

Computer Science Department للآا بساحلا مسق

Programming Languages Course 6803331-4, Chapter Six

Summer Semester of 2018 Academic Year

Associative Arrays

Adding, Accessing and Removing Elements from Perl’s Hashes

Creating a Hash:

#There is more than one way to create a Hash or what’s called an Associative Array in Perl.

$teachers{'Mariah'} = 24;

$teachers{'Lisa'} = 30;

#Another way

%teachers = ('Mariah' => 24, 'Lisa'=> 30);

#Also

%teachers = ('Mariah', 24, 'Lisa', 30);

Accessing a Hash Element:

%teachers = ('Mariah' => 24, 'Lisa'=> 30);

#Simply we can access to an element as this:

print "\Teacher1Age = $teachers{'Mariah'}\n";

print "\Teacher2Age = $teachers{'Lisa'}\n";

The Output:

Teacher1Age = 24 Teacher2Age = 30

Add a Hash Element:

%teachers = ('Mariah' => 24, 'Lisa'=> 30);

print "\Teacher1Age = $teachers{'Mariah'}\n";

print "\Teacher2Age = $teachers{'Lisa'}\n";

#Simply we can add an element as this:

$teachers{'Othman'}=60;

print "\Teacher3Age = $teachers{'Othman'}\n";

The Output:

Teacher1Age = 24 Teacher2Age = 30 Teacher3Age = 60

(2)

2

Kingdom of Saudi Arabia ةيدوعسلا ةيبرعلا ةكلمملا Ministry of Education ميلعتلا ةرازو

Umm AlQura University ىرقلا مأ ةعماج

Adham University College مضأب ةيعماجلا ةيلكلا

Computer Science Department للآا بساحلا مسق

Delete a Hash Element:

%teachers = ('Mariah' => 24, 'Lisa'=> 30);

print "\Teacher1Age = $teachers{'Mariah'}\n";

print "\Teacher2Age = $teachers{'Lisa'}\n";

$teachers{'Othman'}=60;

print "\Teacher3Age = $teachers{'Othman'}\n";

#Simply by the keyword delete:

delete $teachers{'Othman'};

print "\Teacher3Age = $teachers{'Othman'}\n";

The Output:

Teacher1Age = 24 Teacher2Age = 30 Teacher3Age = 60 Teacher3Age =

Reference:

https://www.tutorialspoint.com/perl/perl_hashes.htm

Remember,“Success is 1% inspiration and 99% perspiration”😉 If you have any questions, feel free to ask me through my email

T.Mariah Sami Ahmed Khayat Teacher Assistant @ Adam University College

[email protected]

Referensi

Dokumen terkait

ةيدوعسلا ةيبرعلا ةكلمملا ميلعتلا ةرازو فوجلا ةعماج ةيلك تامولعملاو بساحلا مولع بساحلا ةسدنه مسق تاكبشلاو يللآا Kingdom of Saudi Arabia Ministry of Education Jouf University

ةيدوعسلا ةيبرعلا ةكلمملا Kingdom of Saudi Arabia ميلعتلا ةرازو Ministry of Education فوجلا ةعماج Jouf University ةيويحلا تاياقلاخلل ةمئادلا ةنجللا Local Committee of Bioethics

19 ةيدوعسلا ةيبرعلا ةكلمملا ميلعتلا ةرازو ميصقلا ةعماج ةيلك ةيبرتلا لافطلأا ضاير مسق Kingdom of Saudi Arabia Ministry of Education Al Qussaim university Faculty of Education

ةيدوعسلا ةيبرعلا ةكلمملا ميلعتلا ةرازو نارجن ةعماج ةيبرتلا ةيلك KINGDOM OF SAUDI ARABIA Ministry Of Education Najran University College of Education لافطلأا ضاير مسق

Kingdom of Saudi Arabia Ministry of Higher Education Majmaah University College of Computer & Information Sciences ةيدوعسلا ةيبرعلا ةكلمملا يلاعلا ميلعتلا ةرازو ةعمجملا ةعماج

ةحفصلا نم5 8 ةيدوعسلا ةيبرعلا ةكلمملا ةيئاهنلا تارابتخلاا لودج يلاعلا ميلعتلا ةرازو يساردلا لصفلا ا يناثلا ةعمجملا ةعماج يعماجلا ماعلا -35 ـه36 طاغلاب

Kingdom of Saudi Arabia Ministry of Higher Education Majmaah University College of Computer & Information Sciences ةكلمملا ةيبرعلا ةيدوعسلا ةرازو ميلعتلا يلاعلا ةعماج ةعمجملا

ةيدوعسلا ةيبرعلا ةكلمملا يلاعلا ميلعتلا ةرازو زيزعلادبع كلملا ةعماج ةيلك ةرادلإاو داصتقلاا – ماظتنلااتابلاط KINDOM OF SAUDI ARABIA Ministry of Higher Education KING ABDULAZIZ