Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

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

by scott (Chaplain)
on Apr 24, 2001 at 00:21 UTC ( [id://74859]=note: print w/replies, xml ) Need Help??


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)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://74859]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (3)
As of 2025-01-22 11:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (63 votes). Check out past polls.