#!/opt/local/GNU/bin/perl # uuencode - encode a file for Unix-to-Unix transfer. # # uuencode [source-file] target-file # Reads specified file or standard input and writes # a uuencoded file to standard output. sub usage { die "usage: uuencode [source-file] target-file\n" } &usage if @ARGV > 2 || !@ARGV; $target = pop; $source = @ARGV? shift: "-"; open INPUT, $source or die "uuencode: cannot read $source\n"; @stat = stat INPUT; $mode = @stat? $stat[2]: 0644; $omode = sprintf "%03o", $mode; $pmode = substr $omode, -3; print "begin $pmode $target\n"; while ($inbytes = read INPUT, $instring, 45) { print pack "u", $instring; } print " \nend\n";