File: uudecode.pl

package info (click to toggle)
sharutils 1:4.2-6
  • links: PTS
  • area: main
  • in suites: hamm
  • size: 1,436 kB
  • ctags: 587
  • sloc: ansic: 6,313; perl: 1,742; makefile: 563; sh: 495; pascal: 293; sed: 93
file content (24 lines) | stat: -rw-r--r-- 522 bytes parent folder | download | duplicates (7)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# uuencode in Perl.
# Copyright (C) 1995 Free Software Foundation, Inc.
# Fran´┐Żois Pinard <pinard@iro.umontreal.ca>, 1995.

# `perl uudecode.pl FILES' will decode all uuencoded files found in
# all input FILES, stripping headers and other non uuencoded data.

while (<>)
{
    if (/^begin [0-7][0-7][0-7] ([^\n ]+)$/)
    {
	open (OUTPUT, ">$1") || die "Cannot create $1\n";
	binmode OUTPUT;
	while (<>)
	{
	    last if /^end$/;
	    $block = unpack ("u", $_);
	    print OUTPUT $block;
	}
	close OUTPUT;
    }
}

exit 0;