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});
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.