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

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

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



yanivr78
Novice

Mar 15, 2013, 2:57 AM


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

Hi all,

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


Code
#!/usr/bin/perl 

# 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
@a:
2 4 6 2.4

@b:
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