#!/usr/bin/perl -w # use strict; my ($xmlvar,$i,$k,$v); my %hash = (); while () { print; chomp($_); $i = 0; while ($i++ < length($_)) { print "1: '"; print $1 if /(<)/gc; print "', pos=", pos, "\n"; $k = ''; print "2: '"; $k = $1 if /\G([A-Za-z0-9]+)/gc; print "$k', pos=", pos, "\n"; my $f = '' if defined $k; print "3: '"; print $1 if /(>)/gc; print "', pos=", pos, "\n"; $v = ''; print "4: '"; $v = $1 if /\G(.*)$f/gc; print "$v', pos=", pos, "\n"; $i = pos; print $k,' << ',$v,"\n"; $hash{$k} .= $v.','if defined $k; } print "Final: '$1', pos=",pos,"\n" if /\G(.)/; } s/,\z// for values %hash; while ( my ($key, $value) = each(%hash) ) { print "$key => $value\n"; } __DATA__ dog home pet cathome pet penguin fish lax wile whale fish ostrich bird catfish fish