From: Jo-Philipp Wich Date: Tue, 30 Aug 2022 16:20:04 +0000 (+0200) Subject: scripts: xxdi.pl: remove File::Slurp dependency X-Git-Tag: v21.02.4~25 X-Git-Url: http://git.lede-project.org./?a=commitdiff_plain;h=70124b8579b1c43c9018352adf8e87e1246843c7;p=openwrt%2Fstaging%2Fhauke.git scripts: xxdi.pl: remove File::Slurp dependency In order to make it more portable. Signed-off-by: Jo-Philipp Wich Signed-off-by: Petr Štetiar (cherry picked from commit 8b278a76d90e3724815a5fde32be59f7796be1d8) --- diff --git a/scripts/xxdi.pl b/scripts/xxdi.pl index acc974c4b3..1f960902be 100755 --- a/scripts/xxdi.pl +++ b/scripts/xxdi.pl @@ -14,9 +14,24 @@ use strict; use warnings; -use File::Slurp qw(slurp); -my $indata = slurp(@ARGV ? $ARGV[0] : \*STDIN); +my $indata; + +{ + local $/; + my $fh; + + if (@ARGV) { + open($fh, '<:raw', $ARGV[0]) || die("Unable to open $ARGV[0]: $!\n"); + } else { + $fh = \*STDIN; + } + + $indata = readline $fh; + + close $fh; +} + my $len_data = length($indata); my $num_digits_per_line = 12; my $var_name;