CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
Search Posts SEARCH
Who's Online WHO'S
Log in LOG

Home: Perl Programming Help: Beginner: MAP function and its affect....: Edit Log


Mar 15, 2013, 2:57 AM

Views: 1278
MAP function and its affect....

Hi all,

I have two lists, @a and @b.
after running a function on @b using the below :


# MAP = returns a list of Regexp strings(similar to grep)

@a = (1,2,3,1.2);
@b = map($_ *= 2,@a); # first add *2 to each number from @a

print "\n@a\n";
print "\n@b\n";

I print the lists, and I've found that @a was changed as well from some reason.

In Reply To
2 4 6 2.4

2 4 6 2.4

Can you explain why ?

(This post was edited by yanivr78 on Mar 15, 2013, 2:59 AM)

Edit Log:
Post edited by yanivr78 (Novice) on Mar 15, 2013, 2:59 AM

Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives