Exactly what structure you want to end up with isn't clear, but I assume you that you need to keep the tracks and artists associated with their UPCs. If there were only one upc and one track/artist per line, grouped by upc, it would be easier. The position of the track/artist on each line is what tells you which UPC it is for, but you're losing the position of the UPC when you parse that line.

Katy

On 21 Oct 2003 12:43:45 -0400, Kevin Old <[EMAIL PROTECTED]> wrote:

Hello everyone,

Thanks to everyone who helped with my last problem last week.  I've hit
a snag in another problem this week.

I need to parse the following data:

"COUNTRY MUSIC HALL OF FAME UPC#: 0-84296-22922-2"||||||"COUNTRY FEMALE
PARTY SONGS VOL. 2  UPC#:  0-84296-28682-9"||||||"COUNTRY MALE PARTY
SONGS VOL. 2   UPC#:  0-84296-28652-2"
(....)
" 1. CRAZY"|||"PATSY CLINE"|||" 1. SOME DAYS YOU GOTTA DANCE"|||"DIXIE
CHICKS"|||" 1. THE LONG GOODBYE"|||"BROOKS & DUNN"
" 2. ANGELS AMONG US"|||ALABAMA|||" 2. BLESSED"|||"MARTINA McBRIDE"|||"
2. MY LIST"|||"TOBY KEITH"
(....)
Now, let me explain the data.  There are 3 albums here.  The titles and
UPC's are in the first line.  I have a loop that separates the title and
the piece of the UPC that I need and puts it into a hash.

my %titles = ();
while(<KB>) {

my @songs;
my @artist;
my @line = split/\|/,$_;
foreach ($line[0], $line[6], $line[12]) {

if($_
$_ =~ s/"//g;
$_ =~ /^(.*?)\s+UPC#:\s+0-84296-(\d+)-\d/g;
my $title = $1;
my $upc = $2;
$titles{$upc}{title} = $title;
}

}

Then the rest of the lines are "Tracks" and "Artists".  What I need to
do is get the appropriate tracks and artists in respective (@tracks,
@artists) arrays inside the hash.

Basically, I need to know how to write code that does this:

Get the 3 albums to be processed, put title in hash with UPC as key
(done with code above)

Parse next 16 lines (3 tracks and artists on each line) and associate
them with the proper song & artist arrays in the hash.

I know this is rather confusing, but any help is appreciated!

Kevin






-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to