Perl: map
Tutoring Perl: the tutor gives an example of Perl’s fantastic map function.
Suppose you have the array (1,2,3,4), but you want to musically enhance it to (and a 1, and a 2,….)
@arr=map {‘and a ‘.$_} (1,2,3,4);
yields
@arr = (and a 1, and a 2, and a 3, and a 4)
Source:
Tutorials Point (India) Pvt. Ltd.
Jack of Oracle Tutoring by Jack and Diane, Campbell River, BC.
Leave a Reply
You must be logged in to post a comment.