XML::FeedLite::File - XML::FeedLite::File documentation


XML-FeedLite documentation Contained in the XML-FeedLite distribution.

Index


Code Index:

NAME

Top

XML::FeedLite::File

VERSION

Top

$Revision: 1.3 $

SYNOPSIS

Top

DESCRIPTION

Top

SUBROUTINES/METHODS

Top

fetch - Fetch feed data from file

  $xflf->fetch({
                '/path/to/file1' => sub { ... },
                '/path/to/file2# => sub { ... },
               });

DIAGNOSTICS

Top

CONFIGURATION AND ENVIRONMENT

Top

DEPENDENCIES

Top

INCOMPATIBILITIES

Top

BUGS AND LIMITATIONS

Top

AUTHOR

Top

Roger Pettett, <rmp@psyphi.net>

LICENSE AND COPYRIGHT

Top


XML-FeedLite documentation Contained in the XML-FeedLite distribution.

#########
# Author:        rmp@psyphi.net
# Maintainer:    rmp@psyphi.net
# Created:       2006-06-08
# Last Modified: $Date: 2009/01/09 14:38:54 $
# Id:            $Id: File.pm,v 1.3 2009/01/09 14:38:54 zerojinx Exp $
# Source:        $Source: /cvsroot/xml-feedlite/xml-feedlite/lib/XML/FeedLite/File.pm,v $
# $HeadURL$
#
package XML::FeedLite::File;
use strict;
use warnings;
use base qw(XML::FeedLite);
use English qw(-no_match_vars);
use Carp;

our $VERSION = do { my @r = (q$Revision: 1.3 $ =~ /\d+/smxg); sprintf '%d.'.'%03d' x $#r, @r };

sub fetch {
  my ($self, $url_ref) = @_;

  for my $fn (keys %{$url_ref}) {
    if(!ref $url_ref->{$fn} eq 'CODE') {
      next;
    }

    open my $fh, q(<), $fn or croak $ERRNO;
    local $RS = undef;
    my $xml   = <$fh>;
    close $fh or carp $ERRNO;

    my $cb = $url_ref->{$fn};
    &{$cb}(\$xml); ## no critic
  }
  return;
}

1;

__END__