parsed.org

Tips by tag: map

Processing An Array by xinu on Apr 02, 2008 12:34 AM

In Perl you may have an array you'd like to iterate over. This would work:

for $line (@array) {
    print "line: $line\n";
}

Or you could use this abbreviated method with map():

print map ("line: $_\n") @array;
arraymapperlprint
RSS