in reply to Re: Reporting
in thread Reporting

I think the question was more of which of the following is faster:
if ($#array >= 0) ### or ... if (@array > 0)

------
We are the carpenters and bricklayers of the Information Age.

Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Replies are listed 'Best First'.
Re: Re: Re: Reporting
by diotalevi (Canon) on Apr 04, 2003 at 00:59 UTC

    Both of those are better written as if (@array) {. Its likely to be less ops as well.

Re: Re: Re: Reporting
by l2kashe (Deacon) on Apr 04, 2003 at 05:54 UTC
    Im actually thinking the question was.

    Which is faster?
    $num = scalar(@array); # or $num = $#array;
    And as someone pointed out $#array isnt acurate as to the actual number of elements in the array, so I guess you could simply compare the op trees of the two. Or I guess perform 3 benchmarks,
    1) plain
    2) scalar(@array) - 1
    3) $#array + 1;

    /* And the Creator, against his better judgement, wrote man.c */