in reply to Convert a Tab-Delimeted File to XML
generates#!/usr/bin/perl use XML::Simple; my @file; my (@labels) = split /\s+/, <DATA>; while (<DATA>) { chomp; my %line; @line{@labels} = split /\t/; push @file, \%line; } print XMLout(\@file); __DATA__ First Last Fred Flintstone Barney Rubble Betty Rubble Wilma Flintstone
Season to taste.<opt> <anon First="Fred" Last="Flintstone" /> <anon First="Barney" Last="Rubble" /> <anon First="Betty" Last="Rubble" /> <anon First="Wilma" Last="Flintstone" /> </opt>
-- Randal L. Schwartz, Perl hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Convert a Tab-Delimeted File to XML
by tstock (Curate) on Sep 30, 2001 at 05:26 UTC | |
by jeffa (Bishop) on Sep 30, 2001 at 06:45 UTC | |
by Anonymous Monk on Sep 30, 2001 at 12:57 UTC | |
by maverick (Curate) on Oct 02, 2001 at 02:25 UTC | |
by runrig (Abbot) on Oct 02, 2001 at 03:08 UTC |