Jonathan Epstein <[EMAIL PROTECTED]> writes:
> Now, I ran this program (named tramp_decode_test.pl to avoid namespace conflicts),
>and get this on my Linux system:
>
> echo eHl6enkK | perl tramp_decode_test.pl
> xyzzy
>
> And this on my Solaris system:
> echo eHl6enkK | perl tramp_decode_test.pl
I can reproduce the problem. On SunOS 5.7, Perl 5.005_02, same result
as Jonathan. On HP-UX B.10.20, Perl 5.004_04, there is even an error:
| albinus@slbwba:[1040] echo eHl6enkK | perl tramp_decode_test.pl
| Too many arguments for substr at tramp_decode_test.pl line 29, near "q())"
| Execution of tramp_decode_test.pl aborted due to compilation errors.
Debugging it, you can see:
- "sprintf(q(%06b)" is used. But "%06b" isn't a defined by default for
sprintf.
- In statement "my $chunk = substr($pending, 0, $len & ~3, q());" the
last parameter of substr isn't defined by default (therefore the
error with HP-UX Perl). I guess, it's optional, so not necessary.
The script could be changed as follows:
---
#!/bin/perl
# This script contributed by Juanma Barranquero <[EMAIL PROTECTED]>.
# Copyright (C) 2002 Free Software Foundation, Inc.
use strict;
my %trans = do {
my $i = 0;
map {($_, substr(unpack(q(B8), chr $i++), 2, 6))}
split //, q(ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/);
};
my %bytes = map {(unpack(q(B8), chr $_), chr $_)} 0 .. 255;
binmode(\*STDOUT);
# We are going to accumulate into $pending to accept any line length
# (we do not check they are <= 76 chars as the RFC says)
my $pending = q();
while (my $data = <STDIN>) {
chomp $data;
# If we find one or two =, we have reached the end and
# any following data is to be discarded
my $finished = $data =~ s/(==?).*/$1/;
$pending .= $data;
my $len = length($pending);
my $chunk = substr($pending, 0, $len & ~3);
# Easy method: translate from chars to (pregenerated) six-bit packets, join,
# split in 8-bit chunks and convert back to char.
print join q(),
map $bytes{$_},
((join q(), map {$trans{$_} || q()} split //, $chunk) =~ /......../g);
last if $finished;
}
---
This works for me under Solaris & HP-UX.
Kai, could you please test it under Linux? Here at work I haven't one ...
> Jonathan
Best regards, Michael.
_______________________________________________
Tramp-devel mailing list
[EMAIL PROTECTED]
http://mail.freesoftware.fsf.org/mailman/listinfo/tramp-devel