Matisse Enzer wrote:
>    sub complexity_of_six {
>        my $bar = shift;
>        my $total = 0;
>        my $type = ref $bar;
>        if ( ! $type ) {
>            $total = $bar;
>        }
>        elsif ( $type eq 'ARRAY' ) {
>            foreach my $baz ( @{$bar} ) {
>                $total += $baz;
>            }
>        }
>        else {
>            confess("Don't know how to handle refs to $type");
>        }
>        return $total;
>    }

I'm missing something, I only count 3 paths.  if, elsif and else.  The 
confess() might count (die/throw exception) but its the only path through the 
else.  Same with the loop, its the only path through the elsif.

Also...

    sub foo {
        if( ... ) {
                ...
        }
        else {
                ...
        }

        return ...
    }

Complexity of two or three?  I count only two possible paths.

Reply via email to