Hiya.
I have a XMLTV file that I want to parse to import some info into a mysql database. I had someone help me with the basics, but I am still running into problems.
Original file - http://paste.ubuntu.com/11109433/ (Large File!)
from this file I want to strip some of the nonsense so I can get an output of
UPDATE channel SET channum="101",xmltvid="9601.dvb.guide" WHERE callsi +gn="RTE One");
I have this so far.
#!/usr/bin/perl use v5.14; use warnings; until(eof()) { my ($id, $chan) = <> =~ /id="([^"]*)".*number="(\d+)"/; my ($sign) = <> =~ />(.*)</; <>; # Skip </channel> say qq(UPDATE channel SET channum="$chan",xmltvid="$id" WHERE call +sign="$sign"); }
but when I run it, it never ends it just seems to hang. If I press enter I get some uninitialized warnings (obviously I can stop these with no warnings 'uninitialized'; ) but it seems to get to this line and then stop.
channel id="9001.dvb.guide" <!-- number="65535" type="0x95" flags="0xf +fff" bouquet="4109" region="0" sid="9001" -->> <display-name>[65535.9001.(null)]</display-name>
Any pointers as to where I am going wrong would be great.
Thanks in advance.
S.

In reply to Pasing an XML file to generate a certain output. by Saner

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.