From: "Bill Harpley" <bill.harp...@ericsson.com> > Suppose I have a multidimensional array of the form: > > @array[names][values] > > For example, I have a list of database field names and the value > associated with each one. > > If this was a single dimensional array called @list, I could create an > output line in CSV format by using the 'join' command like this: > > $line= join ',' , @list; > > Is there a simple way to just take a single column of a multidimensional > array and use 'join' to create a CSV output line? > > Must I copy the desired column into a single dimensional array first? > This is the most obvious way but if anybody can think of a neater trick > I would be delighted to know ! > > Regards, > BiLL
I believe you are looking for $line = join ',', map $_[$column_index], @array; The map() selects the right item from each row and creates a list of the values in the column. Jenda ===== je...@krynicky.cz === http://Jenda.Krynicky.cz ===== When it comes to wine, women and song, wizards are allowed to get drunk and croon as much as they like. -- Terry Pratchett in Sourcery -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/