|
|
Tutorials

Perl

|
Topic |
What is map() Function in Perl programming?
|
|
Explanation |
|
The map() function applies a change to a list to get back a new list with the specified
changes.
Syntax:
map EXPR,LIST;
map BLOCK,LIST;
In the above syntax, map() function takes a function or expression and a list as arguments.
Example:
#! C:\programfiles\perl\bin\perl
print "content-type: text/html\n\n";
@color = ('Green','Orange','Blue','Pink','Peach','Black');
@colmap = map(uc, @color);
foreach $key (@colmap)
{
print "$key\n";
}
Result:
GREEN ORANGE BLUE PINK PEACH BLACK
In the above example all the elements of the array "@color" is converted to uppercase and stored
in another array using the map() function.All the elements of the array is printed using a loop.
|
|
A Note |
|
Simple introduction, basic CGI perl programming codes with examples.
Do send your feedback or suggestions on this tutorial.
This is a copyright content.
|
|
|
|