From: Karen Etheridge Date: Thu, 13 Mar 2014 15:27:18 +0000 (+0100) Subject: refactor out _parse_file into the single caller X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=b2ac7cf58e18d608b47355586f161a84f8823e6c;p=p5sagit%2FModule-Metadata.git refactor out _parse_file into the single caller --- diff --git a/lib/Module/Metadata.pm b/lib/Module/Metadata.pm index 0afa14e..9a969c4 100644 --- a/lib/Module/Metadata.pm +++ b/lib/Module/Metadata.pm @@ -383,12 +383,14 @@ sub _init { my $self = bless(\%data, $class); - if ( $handle ) { - $self->_parse_fh($handle); - } - else { - $self->_parse_file(); + if ( not $handle ) { + my $filename = $self->{filename}; + $handle = IO::File->new( $filename ) + or croak( "Can't open '$filename': $!" ); + + $self->_handle_bom($handle, $filename); } + $self->_parse_fh($handle); unless($self->{module} and length($self->{module})) { my ($v, $d, $f) = File::Spec->splitpath($self->{filename}); @@ -461,17 +463,6 @@ sub _parse_version_expression { return ( $sig, $var, $pkg ); } -sub _parse_file { - my $self = shift; - - my $filename = $self->{filename}; - my $fh = IO::File->new( $filename ) - or croak( "Can't open '$filename': $!" ); - - $self->_handle_bom($fh, $filename); - - $self->_parse_fh($fh); -} # Look for a UTF-8/UTF-16BE/UTF-16LE BOM at the beginning of the stream. # If there's one, then skip it and set the :encoding layer appropriately.