Alan M. Carroll wrote:
I went netsearching for this but couldn't find anything in all the noise.

1) What is the runtime cost of the scalar operator? Is it constant or does it 
depend on the size of the array? Is it different than $#array?

2) What's the best way to turn the result of the map function into an array 
reference? Say one has an array of objects and one wants an array reference to 
an array of object IDs. Should I do
A) my @ids = map $_->id, @objs; my $ref = [EMAIL PROTECTED];
B) my $ref = [ map $_->id, @objs ];
C) my $ref = \map $_->id, @objs;

3) Does the answer to (2) depend on which list generating function is called?

Thanks!

_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
Since you've already received the answer to the everything except the runtime cost, I'll try to answer that. According to perlguts, the length of an array is not calculated until the first time it's asked for, after which it's stored. I could be wrong, but according to that, the first time it's called it's a O(n) counting operation and after that it's a constant access.

Oh, and for part 2, I'd go with A, for a map, grep, whatever, for readability.

Sorry for any formatting problems: my mail client has decided to have a mind of it's own.
_______________________________________________
ActivePerl mailing list
ActivePerl@listserv.ActiveState.com
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to