From 41f4eddff561be2db15f7a41bbfd1b830a16a2d0 Mon Sep 17 00:00:00 2001 From: Alex Schroeder Date: Wed, 7 Nov 2007 20:16:15 +0000 Subject: [PATCH] mmencode replacement in Perl --- mimedecode.pl | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 mimedecode.pl diff --git a/mimedecode.pl b/mimedecode.pl new file mode 100644 index 00000000..67862881 --- /dev/null +++ b/mimedecode.pl @@ -0,0 +1,42 @@ +#! /usr/bin/perl + +# Copyright (C) 2007 Alex Schroeder +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +=head1 mimedecode.pl + +This script opens all files given as parameters on the command line +and destructively converts them to binary files. + +Something similar could be achieved using command line tools. +Unfortunately, they are not always available. If Perl's MIME library +is available instead, you can use this script. + +=cut + +use MIME::Base64; + +local $/; +while (<>) { + close ARGV; + if (substr($_,0,6) eq '#FILE ') { + print "$ARGV\n"; + s/^.*\n//; + my $bytes = decode_base64($_); + open(F, "> $ARGV"); + print F $bytes; + close F; + } +}