6 getopts('ushvD', $opts );
8 die usage() if $opts->{h};
10 my $file = shift or die "Need file\n". usage();
11 my $outfile = shift || '';
12 my $mode = (stat($file))[2] & 07777;
14 open my $fh, $file or die "Could not open input file $file: $!";
15 my $str = do { local $/; <$fh> };
22 $outfile =~ s/\.packed$//;
25 $outstr = unpack 'u', $str;
28 $outfile ||= $file . '.packed';
30 $outstr = pack 'u', $str;
37 print "Writing $file into $outfile\n" if $opts->{'v'};
38 open my $outfh, ">$outfile"
39 or die "Could not open $outfile for writing: $!";
43 chmod $mode, $outfile;
46 ### delete source file?
47 if( $opts->{'D'} and $file ne $outfile ) {
53 Usage: $0 [-v] [-s] [-D] SOURCE [OUTPUT_FILE]
54 $0 [-v] [-s] [-D] -u SOURCE [OUTPUT_FILE]
57 uuencodes a file, either to a target file or STDOUT.
58 If no output file is provided, it outputs to SOURCE.packed
62 -s Output to STDOUT rather than OUTPUT_FILE
63 -h Display this help message
64 -u Unpack rather than pack
65 -D Delete source file after encoding/decoding