Hi all, Although I read the usage for grep and map using perldoc -f grep or map I don't think I really get the differences between them.
I have a small data set: my @data=( [1,2,3], [4,5,6], [7,8,9] ); I want to reverse the elements in each row only but not rows themselves I would expect the following output: my @reverse=( [3,2,1], [6,5,4], [9,8,7] ); Here is the script I write. What I find is that the map function will give me the expected result but not the grep function. Any comments? Thanks, Li #!C:/Perl/bin/perl.exe use warnings; use strict; use Data::Dump qw(dump); my @data=( [1,2,3], [4,5,6], [7,8,9] ); my @reverse_map=map{[reverse @[EMAIL PROTECTED]; print "result of using map function\n",dump @reverse_map; my @reverse_grep=grep{[reverse @[EMAIL PROTECTED]; print "\n","result of using grep function\n",dump @reverse_grep; exit; ######output from screen####### result of using map function ([3, 2, 1], [6, 5, 4], [9, 8, 7]) result of using grep function ([1, 2, 3], [4, 5, 6], [7, 8, 9]) __________________________________________________ Do You Yahoo!? Tired of spam? Yahoo! Mail has the best spam protection around http://mail.yahoo.com -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>