|
32 | 32 |
|
33 | 33 | $url_filename or $url_filename = $filename; |
34 | 34 |
|
| 35 | +sub cat { |
| 36 | + open my $fh, '<', $_[0] or die "Can't open file $!"; |
| 37 | + read $fh, my $file_content, -s $fh; |
| 38 | + return $file_content; |
| 39 | +} |
| 40 | + |
35 | 41 | sub localmirrors { |
36 | 42 | my @mlist; |
37 | 43 | open LM, "$scriptdir/localmirrors" and do { |
@@ -203,7 +209,7 @@ sub download |
203 | 209 | copy($link, "$target/$filename.dl"); |
204 | 210 |
|
205 | 211 | $hash_cmd and do { |
206 | | - if (system("cat '$target/$filename.dl' | $hash_cmd > '$target/$filename.hash'")) { |
| 212 | + if (system("$hash_cmd '$target/$filename.dl' > '$target/$filename.hash'")) { |
207 | 213 | print("Failed to generate hash for $filename\n"); |
208 | 214 | return; |
209 | 215 | } |
@@ -233,7 +239,7 @@ sub download |
233 | 239 | } |
234 | 240 |
|
235 | 241 | $hash_cmd and do { |
236 | | - my $sum = `cat "$target/$filename.hash"`; |
| 242 | + my $sum = cat("$target/$filename.hash"); |
237 | 243 | $sum =~ /^(\w+)\s*/ or die "Could not generate file hash\n"; |
238 | 244 | $sum = $1; |
239 | 245 |
|
@@ -299,11 +305,11 @@ sub cleanup |
299 | 305 |
|
300 | 306 | if (-f "$target/$filename") { |
301 | 307 | $hash_cmd and do { |
302 | | - if (system("cat '$target/$filename' | $hash_cmd > '$target/$filename.hash'")) { |
| 308 | + if (system("$hash_cmd '$target/$filename' > '$target/$filename.hash'")) { |
303 | 309 | die "Failed to generate hash for $filename\n"; |
304 | 310 | } |
305 | 311 |
|
306 | | - my $sum = `cat "$target/$filename.hash"`; |
| 312 | + my $sum = cat("$target/$filename.hash"); |
307 | 313 | $sum =~ /^(\w+)\s*/ or die "Could not generate file hash\n"; |
308 | 314 | $sum = $1; |
309 | 315 |
|
|
0 commit comments