Use of Arrays in PERL

Use of Arrays in PERL

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

print "\n\n";
print "SCALAR VARIABLE IN PERL\n";
print "-----------------------\n";
# SCALAR VARIABLE IN PERL
$EmployeeName="Noor Hasan";
print $EmployeeName;

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";

Use of Arrays in PERL

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

Use of 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..