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: Re: [BillKSmith] Dereference an array: Edit Log



Olive
New User

Oct 14, 2017, 3:20 PM


Views: 2197
Re: [BillKSmith] Dereference an array

Having read the definition of typeglobs you mention, it seems that it can accomplish exactly what I originally asked:


Code
my $a = ["a","b","c","d"];  
*b = $a;

$b[1] = "hello";

print $a->[1];
print "\n";

print $b[1];
print "\n";


both print hello. Is it bad practice? Is it something that I have overlooked. As for the subroutine, I had more in mind avoiding unnecessary extra copies than modifying the arguments. Anyway, in Python, you can do "list.sort()" that sort the list in place. Would it be bad practise to make something similar in perl? There are functions (push) that I think add elements to an existing array.


(This post was edited by Olive on Oct 14, 2017, 3:28 PM)


Edit Log:
Post edited by Olive (New User) on Oct 14, 2017, 3:21 PM
Post edited by Olive (New User) on Oct 14, 2017, 3:25 PM
Post edited by Olive (New User) on Oct 14, 2017, 3:28 PM


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

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