in reply to Re: Short (and clever?) CSV-to-AoA
in thread Short (and clever?) CSV-to-AoA

1. You assign to an array in a for loop. That usually is a sign for something inefficient.

It seemed more 'cool' to me than inefficient. I particularly liked the fact that I could get away with only one synthetic variable and that a loop counter (of sorts). Why is it inefficient?

2. Your use of $#i will put all data in one array, so you technically don't have an AoA, but just an array.

Errr ... but it *does* produce an AoA.

print join( ', ' , @AoA ) , "\n";
Gives
ARRAY(0x1b9528c), ARRAY(0x1b952a4), ARRAY(0x1b952d4)

3. You can loose the push/pop mechanism ...

See my comment to merlyn.

Replies are listed 'Best First'.
Re:{3} Short (and clever?) CSV-to-AoA
by jeroenes (Priest) on Apr 24, 2001 at 09:10 UTC
    Mea culpa, I clearly missed the fact that you were transposing the table. But the other things stay.


    1. Assigning in a for loop is something that goes automagically. If there is the need to assign to an array in something that already works on an array, that should ring a bell that something is inefficient there. Your for loop actually is an assignment and a conditional statement.That maybe nice for obfuscation (well, not really, but a bit maybe), but not cool IMHO.


    3. As merlyn responded, you can rewrite that to a map, too.

    Jeroen
    "We are not alone"(FZ)