Use local implementation of slurp()
authorDavor Ocelic <docelic@crystallabs.io>
Mon, 06 May 2019 21:11:13 +0200
changeset 118 2d7f16eff198
parent 117 eb1bcbaf9763
child 119 a6c211de24f0
Use local implementation of slurp()
shelldap
--- a/shelldap	Sun May 05 10:51:34 2019 +0200
+++ b/shelldap	Mon May 06 21:11:13 2019 +0200
@@ -548,7 +548,7 @@
 use Carp 'confess';
 use POSIX qw//;
 use Tie::IxHash qw//;
-use Perl6::Slurp qw/slurp/;
+use Fatal qw/open/;
 use base 'Term::Shell';
 
 my $conf = $main::conf;
@@ -716,7 +716,7 @@
 		} elsif($conf->{'pass'}) {
 			$conf->{'bindpass'} = $conf->{'pass'}
 		} elsif($conf->{'passfile'}) {
-			chomp( $conf->{'bindpass'} = slurp $conf->{'passfile'} );
+			chomp( $conf->{'bindpass'} = slurp($conf->{'passfile'}));
 		}
 	}
 
@@ -869,7 +869,7 @@
 	my $file = shift or return;
 
 	my $md5 = Digest::MD5->new();
-	open F, $file or die "Unable to read file: $!\n";
+	open F, $file;
 	my $hash = $md5->addfile( *F )->hexdigest();
 	close F;
 
@@ -2006,7 +2006,7 @@
 	}
 
 	# load it into an array for potential comparison
-	open LDIF, "$self->{'ldif_fname'}" or return;
+	open LDIF, "$self->{'ldif_fname'}";
 	my @orig_ldif = <LDIF>;
 	close LDIF;
 
@@ -2056,7 +2056,7 @@
 
 	# load changes into a new array for comparison
 	#
-	open LDIF, "$self->{'ldif_fname'}" or return;
+	open LDIF, "$self->{'ldif_fname'}";
 	my @new_ldif = <LDIF>;
 	close LDIF;
 
@@ -2754,7 +2754,7 @@
 	}
 	$confpath or return undef;
 
-	open YAML, $confpath or return undef;
+	open YAML, $confpath;
 	do {
 		local $/ = undef;
 		$data = <YAML>;  # slurp!
@@ -2795,5 +2795,14 @@
 	return 1;
 }
 
+sub slurp
+{
+	open my $fh, '<:encoding(UTF-8)', $_[0];
+	local $/;
+	my $ret = <$fh>;
+	close $fh;
+	return $ret;
+};
+
 ### EOF