The only problem is that this implementation
requires the keys to be reverse sorted (longest
to shortest-- remove the "reverse" on the sort
and it breaks). To handle unordered names, try
this (note: I eliminated the replication of
parent hash node keys, as a personal preference):
use strict;
use
Andy,
You need to put the CSV file handling to binary mode.
Note, though, when I did, I had to add code to break
out of the loop as the while always returned true.
This code works as you desire, I believe.
hth,
--rich
#!/usr/bin/perl
use IO::File;
use Text::CSV_XS;
$csv = Text::CSV_XS->new({'bi