Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Merge pull request #2 from tokuhirom/no-DATA-fix

get_data_section($name) should not die if there is no __DATA__ section.
  • Loading branch information...
commit adc26fc584a4bffc3543263d84bc76ab4e9c09b6 2 parents 54d684f + 2a1d088
@miyagawa authored
Showing with 10 additions and 1 deletion.
  1. +3 −1 lib/Data/Section/Simple.pm
  2. +7 −0 t/no-datat.t
View
4 lib/Data/Section/Simple.pm
@@ -16,7 +16,9 @@ sub get_data_section {
my $self = ref $_[0] ? shift : __PACKAGE__->new(scalar caller);
if (@_) {
- return $self->get_data_section->{$_[0]};
+ my $all = $self->get_data_section;
+ return unless $all;
+ return $all->{$_[0]};
} else {
my $d = do { no strict 'refs'; \*{$self->{package}."::DATA"} };
return unless defined fileno $d;
View
7 t/no-datat.t
@@ -0,0 +1,7 @@
+use strict;
+use Data::Section::Simple qw(get_data_section);
+use Test::More;
+
+is get_data_section('foo.html'), undef, 'Do not die.';
+
+done_testing;
Please sign in to comment.
Something went wrong with that request. Please try again.