Use of Hash Arrays in PERL

Use of Hash Arrays in PERL

create a file named "perl-tutorial-example-use-of-hash-array.pl" then copy and paste the below code:

print "\n\n";
print "ARRAYS IN PERL\n";
print "--------------\n";
# ARRAYS IN PERL
@Departments=("Enterprise & Financial System Mgt.", "Communication Solution Mgt.", "DBA");
print @Departments;

print "\n\n";
print "ACCESSING ARRAYS IN PERL\n";
print "------------------------\n";
# ACCESSING ARRAYS IN PERL
print $Departments[0], " , ", $Departments[2];
print "\n\n";

print "\n\n";
print "HASH ARRAYS IN PERL\n";
print "-------------------\n";
# HASH ARRAYS IN PERL
%Divisions=(
   "OP" => "Operations",
   "TH" => "Technology",
   "CL" => "Commercials"
);
print %Divisions;

print "\n\n";
print "ACCESSING HASH ARRAYS IN PERL\n";
print "-----------------------------\n";
# ACCESSING ARRAYS IN PERL
print $Divisions{'OP'}, " , ", $Divisions{'TH'};
print "\n\n";

Use of Hash Arrays in PERL

Now run the program (perl-tutorial-example-use-of-hash-array.pl) from command prompt & get some interesting results as follows:

Use of Hash Arrays in PERL - output in the windows command prompt

The result in the windows command prompt

No comments:

Post a Comment

leave your comments here..