20 pts.
 Map function in Perl
Can someone explain me the meaning of this perl function- map { s/^(.+?logd{6}.txt:)//, s/ (save) / *$1* /, $pagestats .= "$_" } @rpagestats;

Software/Hardware used:
ASKED: October 1, 2008  7:39 AM
UPDATED: October 1, 2008  6:24 PM

Answer Wiki:
It is basically a combination of the map function, and regular expressions. The map function (map EXPR,LIST) evaluate EXPR for each element of LIST and returns the list value composed of the result of the evalutaion on each element of LIST. In this case, @rpagestats is the list. The first parameter for the map function is { s/^(.+?logd{6}.txt:)//, s/ (save) / *$1* /, $pagestats .= "$_" }. Here are some hints for you to understand these regular expressions: s/ = means that a substitution will be made. (Example: s/STRING A/STRING B/ will replace STRING A with STRING B) ^ = means that the string that is to be matched must appear at the beginning of the text . = match any character + = match 1 or more times ? = match 0 or more times d{n} = match exactly n digits . = match a "." (dot) Have a look at the following pages. they will help you a lot. <a href="http://perldoc.perl.org/functions/map.html">Perl Map function</a> <a href="http://www.troubleshooters.com/codecorn/littperl/perlreg.htm">Perl Regular Expressions</a> Good luck. -Carlosdl
Last Wiki Answer Submitted:  October 1, 2008  6:23 pm  by  carlosdl   63,535 pts.
All Answer Wiki Contributors:  carlosdl   63,535 pts.
To see all answers submitted to the Answer Wiki: View Answer History.


Discuss This Question:
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _