Xref: utzoo news.software.b:4523 comp.lang.perl:1037 Path: utzoo!utstat!helios.physics.utoronto.ca!news-server.csri.toronto.edu!cs.utexas.edu!tut.cis.ohio-state.edu!ucbvax!iwarp.intel.com!news From: merlyn@iwarp.intel.com (Randal Schwartz) Newsgroups: news.software.b,comp.lang.perl Subject: unpacker in Perl (was Re: stupid Cnews question about comp.mail.maps) Message-ID: <1990Apr9.051333.29144@iwarp.intel.com> Date: 9 Apr 90 05:13:33 GMT References: <1990Apr5.224333.24668@cs.umn.edu> <1990Apr9.005506.5778@utstat.uucp> Sender: news@iwarp.intel.com Reply-To: merlyn@iwarp.intel.com (Randal Schwartz) Organization: Stonehenge; netaccess via Intel, Beaverton, Oregon, USA Lines: 45 In-Reply-To: geoff@utstat.uucp (Geoff Collyer) In article <1990Apr9.005506.5778@utstat.uucp>, geoff@utstat (Geoff Collyer) writes: | C news doesn't unpack maps automagically; you have to put something in your | sys file. Some people run uuhosts from their sys files for comp.mail.maps. I've got this unpacker in Perl that I've been using for a few months. I call it "map-unpacker", and leave it lying about in the map directory. Don't call it something that is a legal map name (like "mapunpacker") or you will find it replaced someday with a trojan horse! (Legal mapnames are defined by the regex in the line following "bad filename" below...) ================================================== cut here #!/local/merlyn/bin/perl $mapdir = "/usr/spool/news/comp.mail.maps"; umask 002; chdir $mapdir || die "Cannot chdir $mapdir ($!)"; $exit = 0; while (<>) { next unless /^cat << 'SHAR_EOF' > (\S+)$/; $SHAR = $1; (warn "bad filename: $SHAR"), $exit++, next unless $SHAR =~ /^[a-zA-Z0-9.]+$/; open(SHAR,">$SHAR") || warn "cannot open $SHAR ($!)"; while (<>) { last if /^SHAR_EOF/; print SHAR $_; } close(SHAR); } ================================================== cut here My sys entry looks like: ME-maps:comp.mail.maps/all::/usr/spool/news/comp.mail.maps/map-unpacker Just another Cnews admin and Perl hacker, -- /=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!"=/