| WWW-Mixi-Scraper documentation | Contained in the WWW-Mixi-Scraper distribution. |
WWW::Mixi::Scraper::Utils - internal utilities
Used internally.
Kenichi Ishigaki, <ishigaki at cpan.org>
Copyright (C) 2007 by Kenichi Ishigaki.
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.
| WWW-Mixi-Scraper documentation | Contained in the WWW-Mixi-Scraper distribution. |
package WWW::Mixi::Scraper::Utils; use strict; use warnings; use base qw/Exporter/; use URI; use URI::QueryParam; our @EXPORT_OK = qw( _force_arrayref _uri _datetime ); sub _force_arrayref { my $thingy = shift; return [] if !defined $thingy || $thingy eq ''; return [$thingy] if ref $thingy ne 'ARRAY'; return $thingy; } sub _datetime { my $date = shift; unless ( defined $date ) { warn "datetime is not defined"; return; } my $time; if ( $date =~ s/\s*(\d+:\d+(?::\d+)?)\s*$// ) { $time = $1; } $date =~ s/\D/\-/g; $date =~ s/\-+$//; return $time ? "$date $time" : $date; # should be DateTime object? } sub _uri { my $uri = URI->new(shift); $uri->authority('mixi.jp') unless $uri->authority; $uri->scheme('http') unless $uri->scheme; return $uri; } 1; __END__