Not elegant, but kinda cute. It may work, depending on how strictly your data conforms to this format (minus the typo you had at reference1_title).
use Data::Dumper; my $line = qq(<Reference1> <reference1_name>jvdsj</reference1_name> <r +eference1_address>1234 gjrdkjpigkdj jkgpifodsjgi</reference1_address> + <reference1_title>njhdaslj</reference1_title> <reference1_company> j +hfdsalh</reference1_company> <reference1_csz>Los Angeles, CA,91406</r +eference1_csz><reference1_phone> 818-555-1212</reference1_phone> <ref +erence1_email>wabbit\@acme.com</reference1_email></Reference1>); my %record = reverse split /<\/(\w+)>/, $line; foreach (keys %record) { $record{$_} =~ s/<[^>]+>//g; # remove start tags $record{$_} =~ s/^\s+//; # remove extra whitespace $record{$_} =~ s/\s+$//; delete $record{$_} unless $record{$_}; # kill the outermost record + tag } print Dumper(\%record); PRINTS: $VAR1 = { 'reference1_name' => 'jvdsj', 'reference1_address' => '1234 gjrdkjpigkdj jkgpifodsjgi', 'reference1_title' => 'njhdaslj', 'reference1_company' => 'jhfdsalh', 'reference1_csz' => 'Los Angeles, CA,91406', 'reference1_phone' => '818-555-1212', 'reference1_email' => 'wabbit@acme.com' };


BTW, sorry about the unnecessary 'consider' for code tags -- I need more coffee.

Updated: Thanks, ar0n. Blame it on the coffee again.

In reply to Re: Parsing pseudo XML files by joealba
in thread Parsing pseudo XML files by BMaximus

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.