fayland has asked for the wisdom of the Perl Monks concerning the following question:

I use XML::Feed to write RSS and Atom, but I need both RSS and Atom. so I had to write like this:
my $rss = XML::Feed->new('RSS');
$rss->title( $title );
$rss->link( $site_prefix );
$rss->description($description);
my $atom = XML::Feed->new('Atom');
$atom->title( $title );
$atom->link( $site_prefix );
$atom->description($description);
is there an easy way to simplify this? many thanks.

Replies are listed 'Best First'.
Re: How can I write both RSS and Atom
by Fletch (Bishop) on Dec 12, 2005 at 13:54 UTC
    my %feeds; for my $type ( qw( RSS Atom ) ) { my $feed = XML::Feed->new( $type ); $feed->title( $title ); $feed->link( $site_prefix ); $feed->description( $description ); $feeds{ $type } = $feed; }

    Update: Fixed case typo (ATOM to Atom).

      Thanks. but I find that XML::Atom only create 0.3 Atom, does any module create the version='1.0' Atom?
      or any suggestion when you create your Atom/RSS feeds?
        Hi fayland,

        Which version of XML::Atom do you have?
        As of version 0.13_01 (dated 2005.09.13) you can pass new(Version => 1.0) to create an Atom version 1.0 feed. Check out the 'Changes' file that comes with the module for more information.

        Hope this helps..

        Martin