Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!uwm.edu!zaphod.mps.ohio-state.edu!brutus.cs.uiuc.edu!apple!olivea!orc!inews!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: comp.lang.perl Subject: Re: Uudecode in Perl? Message-ID: <1990Sep3.030730.256@iwarp.intel.com> Date: 3 Sep 90 03:07:30 GMT References: Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 30 In-Reply-To: cybrspc!roy@cs.umn.edu (Roy M. Silvernail) In article , cybrspc!roy@cs (Roy M. Silvernail) writes: | Has anyone implemented UUdecode in Perl? | | I'm working on a Perl project (targeted at MS-DOS) that will include | UUdecoding files. In the interest of conserving disk overhead, I'd | rather not create a temp file and spawn UUdecode. I'd rather just | accomplish the whole project in Perl. If a Perl UUdecode already has | been written, it would save me re-inventing a wheel. It's nearly trivial in pl28... (From "the book", written by lwall...) ================================================== snip #!/usr/bin/perl $_ = <> until ($mode,$file) = /^begin\s*(\d*)\s*(\S*)/; open(OUT,"> $file") if $file ne ""; while (<>) { last if /^end/; next if /[a-z]/; next unless int((((ord() - 32) & 077) + 2) / 3) == int(length() / 4); print OUT unpack("u", $_); } chmod oct($mode), $file; ================================================== snip -- /=Randal L. Schwartz, Stonehenge Consulting Services (503)777-0095 ==========\ | on contract to Intel's iWarp project, Beaverton, Oregon, USA, Sol III | | merlyn@iwarp.intel.com ...!any-MX-mailer-like-uunet!iwarp.intel.com!merlyn | \=Cute Quote: "Welcome to Portland, Oregon, home of the California Raisins!"=/