Greetings Avout.

Why does this code not return feed titles or URLs? Even the dump does not look like what I expect. UPDATE fixed, but still not sure why the dump of $e looked so strange.

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; use feature 'say'; use local::lib; use XML::Feed; my $args = ({}); $args->{debug} = 1; sub atom_feed { my ( $arg ) = @_; # Set defaults # If option given my $newer_than = exists $arg->{newer_than} ? $arg->{newer_than} : 6000; my $url = $arg->{url}; my @events; warn "\n>>>> Getting atom url for [$url] ". "records newer than [$newer_than]min" if $args->{debug}; my $feed = XML::Feed->parse( URI->new( $url )) or die "Feed error with [$url] ".XML::Feed->errstr; my $x=1; for my $e ( $feed->entries ) { last if $x == 3; warn Dumper( $e ) if $args->{debug}; # << looks weird warn "Got bug title [$e->title]" if $args->{debug}; # << nothing if ( $e->title =~ m/\A\w+ # Start with any word \s+ # UPDATE << forgot this! \#\d{4,5} # bug number \s+ \( (Open|Closed|Merged|Rejected) \) # Status of bug /ix ) { push @events, $e->title .", ". $e->link; } $x++; } say $_ foreach ( @events ); # empty !? return \@events; } atom_feed({ url => 'https://dev.cfengine.com/projects/core/activity.atom' }); atom_feed({ url => 'http://www.redmine.org/projects/redmine/activity.atom' }); $ ./atom.pl Warning: XML::LibXML compiled against libxml2 20902, but runtime libxm +l2 is older 20901 >>>> Getting atom url for [https://dev.cfengine.com/projects/core/activity.atom] records newe +r than [6000]min at ./atom.pl line 22. $VAR1 = bless( { 'entry' => bless( { 'version' => '0.3', 'elem' => bless( do{\(my $o = 68470752)}, 'XML::LibXML::Element +' ), 'ns' => 'http://www.w3.org/2005/Atom' }, 'XML::Atom::Entry' ) }, 'XML::Feed::Entry::Format::Atom' ); Got bug title [XML::Feed::Entry::Format::Atom=HASH(0x43b0968)->title] +at ./atom.pl line 33. $VAR1 = bless( { 'entry' => bless( { 'ns' => 'http://www.w3.org/2005/Atom', 'elem' => bless( do{\(my $o = 68348704)}, 'XML::LibXML::Element +' ), 'version' => '0.3' }, 'XML::Atom::Entry' ) }, 'XML::Feed::Entry::Format::Atom' ); Got bug title [XML::Feed::Entry::Format::Atom=HASH(0x3ac4918)->title] +at ./atom.pl line 33. >>>> Getting atom url for [http://www.redmine.org/projects/redmine/activity.atom] records new +er than [6000]min at ./atom.pl line 22. $VAR1 = bless( { 'entry' => bless( { 'version' => '0.3', 'elem' => bless( do{\(my $o = 68856240)}, 'XML::LibXML::Elem +ent' ), 'ns' => 'http://www.w3.org/2005/Atom' }, 'XML::Atom::Entry' ) }, 'XML::Feed::Entry::Format::Atom' ); Got bug title [XML::Feed::Entry::Format::Atom=HASH(0x3b02bd0)->title] +at ./atom.pl line 33. $VAR1 = bless( { 'entry' => bless( { 'version' => '0.3', 'ns' => 'http://www.w3.org/2005/Atom', 'elem' => bless( do{\(my $o = 67673440)}, 'XML::LibXML::Elem +ent' ) }, 'XML::Atom::Entry' ) }, 'XML::Feed::Entry::Format::Atom' ); Got bug title [XML::Feed::Entry::Format::Atom=HASH(0x3f782c8)->title] +at ./atom.pl line 33.

Neil Watson
watson-wilson.ca


In reply to XML::Feed not working by neilwatson

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.