home *** CD-ROM | disk | FTP | other *** search
/ ftp.cse.unsw.edu.au / 2014.06.ftp.cse.unsw.edu.au.tar / ftp.cse.unsw.edu.au / pub / doc / languages / perl / nutshell / ch4 / uudecode < prev    next >
Encoding:
Text File  |  1992-10-18  |  284 b   |  12 lines

  1. #!/usr/bin/perl
  2. $_ = <> until ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/;
  3. open(OUT,"> $file") if $file ne "";
  4. while (<>) {
  5.     last if /^end/;
  6.     next if /[a-z]/;
  7.     next unless int((((ord() - 32) & 077) + 2) / 3) ==
  8.         int(length() / 4);
  9.     print OUT unpack("u", $_);
  10. }
  11. chmod oct($mode), $file;
  12.