what does the print map state?
Okay,
print join("\n", @array), "\n";
says "Stick a newline between each element in
@array, return that as a string, print it, and
print a newline at the end." On the other hand,
print map {$_ . "\n"} @array;
says "Build a list whose elements are the elements of
@array with "\n" appended to them, then print
that list."
what perldoc can I read about the map call?
You can read about any function with
perldoc -f func_name.
--
F
o
x
t
r
o
t
U
n
i
f
o
r
m
Found a typo in this node? /msg me
% man 3 strfry
| [reply] [d/l] [select] |
#!/usr/bin/perl
use strict;
use warnings;
my @array = (1..10);
local $, = "\n";
print @array;
| [reply] [d/l] [select] |
perldoc -f map.
map is a list-transformer; you give it a block of code and a list, and it applies the code to each element of the list, and returns a list made up of what the code returned for each element. | [reply] |
You can read perlfunc to find out about map. Also, the easiest way to print all the elements of an array is:
print "@array\n";
| [reply] [d/l] |