decoding MIME:Base64 question?

2004-01-13 Thread Tino Arellano

Hello folks,

If I encode a file with MIME::Base64 with the following script,  encode_base64.pl. The 
question is; how do I decode 
the file?  I use the following script, decode_base64.pl to decode back to the original 
source but that did not work because 
they are different from each other. 

Thank you...



-encode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_R, rap_arms.blend) or die $!;
open(FILE_W, rap_arms.bas64) or die $!;
   
   while (read(FILE_R, $buf, 60*57)) {
   $encoded = MIME::Base64::encode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print Done ... \n;


-decode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_W, rap_arms.new.blend) or die $!;
open(FILE_R, rap_arms.bas64) or die $!;
   
   while (read(FILE_R, $buf,60*57)) {
   $encoded = MIME::Base64::decode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print Done ... \n;








-- 
__
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




decoding a base64 file?

2004-01-13 Thread Tino Arellano

Hello folks,

If I encode a file with MIME::Base64 with the following script, encode_base64.pl. The 

question is; how do I decode the file?  I use the following script, decode_base64.pl 
to 

decode back to the original source but that did not work.

Thank you...



-encode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_R, rap_arms.blend) or die $!;
open(FILE_W, rap_arms.bas64) or die $!;
   
   while (read(FILE_R, $buf, 60*57)) {
   $encoded = MIME::Base64::encode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print Done ... \n;


-decode_base64.pl

#! /usr/bin/perl
   
   
   
   use MIME::Base64 ();
   

open(FILE_W, rap_arms.new.blend) or die $!;
open(FILE_R, rap_arms.bas64) or die $!;
   
   while (read(FILE_R, $buf, 60*57 )) {
   $encoded = MIME::Base64::decode($buf);
   print FILE_W $encoded ;
   
   }  
close(FILE_R);
close(FILE_W);
   
   print Done ... \n;



--
-- 
__
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response




coping txt files over a peer to peer.

2004-01-07 Thread Tino Arellano
Hello folks,

How do I send the file name used by the client so that the server uses the same file 
name 
When it is writing it own file. 


thank you.

here's the client: 

use IO::Socket;

my $server = IO::Socket::INET-ne­w(
   PeerAddr = 'localhost',
   PeerPort = 5050,
   Proto= 'tcp'
) or die Can't create client socket: $!;


open FILE, original_file_name;
while (FILE) {
  print $server $_;
  }
close FILE;


Here's the server:

use IO::Socket;

my $server = IO::Socket::INET-ne­w(
   Listen = 5,
   LocalAddr = 'localhost',
   LocalPort = 5050,
   Proto = 'tcp'
) or die Can't create server socket: $!;

my $client = $server-accept;


open FILE, copy_file_name or die Can't open: $!;
 while ($client) {
   print FILE $_;
   }
close FILE;


--






-- 
__
Check out the latest SMS services @ http://www.linuxmail.org 
This allows you to send and receive SMS through your mailbox.


Powered by Outblaze

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/ http://learn.perl.org/first-response