1
0
mirror of https://git.FreeBSD.org/src.git synced 2024-12-24 11:29:10 +00:00
freebsd/contrib/perl5/eg/uudecode

16 lines
416 B
Perl

#!/usr/bin/perl
while (<>) {
next unless ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/;
open(OUT,"> $file") || die "Can't create $file: $!\n";
while (<>) {
last if /^end/;
next if /[a-z]/;
next unless int((((ord() - 32) & 077) + 2) / 3) ==
int(length() / 4);
print OUT unpack("u", $_);
}
chmod oct($mode), $file;
eof() && die "Missing end: $file may be truncated.\n";
}