Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!sdd.hp.com!elroy.jpl.nasa.gov!jpl-devvax!lwall From: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Newsgroups: comp.lang.perl Subject: Re: uuencode in perl? Message-ID: <11368@jpl-devvax.JPL.NASA.GOV> Date: 9 Feb 91 02:05:08 GMT References: <1991Feb6.091933.27961@lth.se> Reply-To: lwall@jpl-devvax.JPL.NASA.GOV (Larry Wall) Organization: Jet Propulsion Laboratory, Pasadena, CA Lines: 101 In article <1991Feb6.091933.27961@lth.se> jh@efd.lth.se (Joergen Haegg) writes: : : I was trying to write a uuencode/uudecode program in perl. : (Yes, I know, the c-version is free, but it's fun to try ;-) : Not very difficult, since pack has 'u'. : But I compared the output with Suns uuencode: : : sub encode : { : ($name, $file, @x) = @_; : : $st_mode = 0622; : if ($file) : { : &Stat($file) || die "stat $file: $!"; : } : printf OUT "begin %03o %s\n", $st_mode&0777, $file; : : open(IN, $file) || die "open $file: $!"; : : while (($n = sysread(IN, $row, 45)) > 0) : { : $uline = pack("u", $row); : print OUT "$uline"; : } : close (IN); : print OUT "\nend\n"; : } : : Testfile: : PID TT STAT TIME COMMAND : 17364 p2 S 7:12 bash -login : 17582 p2 TW 0:04 view ../route.c : 18371 p2 R 0:00 ps : 2505 p4 I 2:31 -su (bash) : 18369 p4 I 0:00 vi uued : : : This script gave : begin 644 z : M("!0240@5%0@4U1!5" @5$E-12!#3TU-04Y$"C$W,S8T(' R(%,@(" @(#