in reply to Chomp an AoA?

First of all, why would you want to chomp anything that did not directly result from a <> read? perlfunc states that chomp chomps a trailing $/, which you are guaranteed only to see when reading using <> brackets... I always do the chomp as the first statement in the loop. When I'm in a daring mood I even put it in the while clause...

Secondly, I think you might be mistaking an array for a list... Which I always did until I read Arrays are not lists by tilly. If that is the case, then chomp would probably work if you did:

chomp @Array[0..$#Array];

If that ain't it, I humbly apologize... :)

Update: Read original post again; seems logical to me chomp won't work as you suggest; an AoA is really an AoRA (Array of references to arrays) and you can hardly expect chomp to merily go dereferencing elements of the array it's passed...

I am now even more so convinced the chomp should just be moved up in the loop, where it belongs...

Replies are listed 'Best First'.
Re: Re: Chomp an AoA?
by PodMaster (Abbot) on Jan 29, 2003 at 15:29 UTC
    You are exactly right. He should be chomp'ing in his while loop, right between next unless (@Fields == 7); and push @Array , [ @Fields[0,3,6] ];. A nice juicy chomp @Array;


    MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
    ** The Third rule of perl club is a statement of fact: pod is sexy.