Re: cat binary file

2002-06-20 Thread Gary Stainburn

Hi Bob,

On Thursday 20 June 2002 4:38 pm, Bob Showalter wrote:
  -Original Message-
  From: Gary Stainburn [mailto:[EMAIL PROTECTED]]
  Sent: Thursday, June 20, 2002 10:57 AM
  To: [EMAIL PROTECTED]
  Subject: cat binary file
 
 
  Hi all,
 
  I know this is a FAQ, but I can't seem to find it.
 
  What's the best way to cat a binary (file with non-display
  chars) to STDOUT?

   $ cat thefile

The point was that I was doing this at the end of a quite long perl script, 
and wanted to do it from within that script. The alternative of using 
system() to call cat would have been inefficient and would may had buffering 
problems too.

As you will see from elsewhere on the thread, I did come up with a suitable 
answer.


  The script is a CGI that generates a ps file, uses ps2pdf to
  convert to a PDF
  file and then will squirt (with appropriate HTTP header) the
  PDF to the
  browser.

 I don't see what this has to do with the question above. Are you
 asking how to send a PDF file back to the browser?

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: cat binary file

2002-06-20 Thread Bob Showalter

 -Original Message-
 From: Gary Stainburn [mailto:[EMAIL PROTECTED]]
 Sent: Thursday, June 20, 2002 12:11 PM
 To: Bob Showalter; [EMAIL PROTECTED]
 Subject: Re: cat binary file
 
 ...
 The point was that I was doing this at the end of a quite 
 long perl script, 
 and wanted to do it from within that script. The alternative of using 
 system() to call cat would have been inefficient and would 
 may had buffering 
 problems too.

OK, I see now. In that case, look at sysopen() and sysread(). That
will let you read fixed-size chunks of the file with no buffering.
Then just print() each chunk to send it back to the browser.

Remember that Content-type and Content-disposition headers will control
how the browser interprets the file coming back.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: cat binary file

2002-06-20 Thread Gary Stainburn

On Thursday 20 June 2002 4:34 pm, David T-G wrote:
 Gary --

 ...and then Gary Stainburn said...
 %
 % On Thursday 20 June 2002 3:56 pm, Gary Stainburn wrote:
 % 
 ...
 %  What's the best way to cat a binary (file with non-display chars) to
 %  STDOUT?
 ...
 % open(FIN,$fname.pdf) || dodie(cannot access PDF: $!\n;
 % print Content-Type: text/html\n\n;
 % while (sysread FIN, $buffer, 4096) {
 %   print $buffer);
 % }
 % close FIN;

 I haven't tested this, and you probably have and have found it lacking,
 but you don't mention it twice...  Have you tried just printing the
 filehandle without anything special?  I should think that if you

   ...
   open (FIN, $fname.pdf) ...
   ...
   while(FIN) {print};
   close FIN;

Hi David,

I could have done that, and with a purely text file I would have.

However, with binary files there can be a hell of a lot of characters between 
the newlines.  This way, the largest block read will be 4K.  

Also, if there are lots of short lines, this way will be more efficiet.


 then it would suck it in and spit it out.  You could probably even reset
 some punctuation vars and squirt through the whole thing in one pass
 rather than stopping on any newlines you might happen to find...


 HTH  HAND

 :-D

-- 
Gary Stainburn
 
This email does not contain private or confidential material as it
may be snooped on by interested government parties for unknown
and undisclosed purposes - Regulation of Investigatory Powers Act, 2000 

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: cat binary file

2002-06-20 Thread Todd Wade

Gary Stainburn wrote:

 On Thursday 20 June 2002 3:56 pm, Gary Stainburn wrote:
 
 open(FIN,$fname.pdf) || dodie(cannot access PDF: $!\n;
 print Content-Type: text/html\n\n;
 while (sysread FIN, $buffer, 4096) {
   print $buffer);
 }
 close FIN;
 

This is how to do it.

Todd W.

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




Re: cat a file

2001-08-17 Thread Walnut

Open them both in Outlook and drag the emails from one to the other.
DO NOT try it any other way or you will corrupt the files.


On Thu, 19 Apr 2001 16:27:31 -0400, [EMAIL PROTECTED]
(Frank Drain) wrote:

Hello,
 
I am very new to perl.  I have two pst (personal folder files) that I want
to combine into one.
 
I know how to use cat in Linux. How do do this 
same operation in perl under windows?
 
Thank You, 
 
Frank Drain
 


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]




RE: cat a file

2001-04-19 Thread King, Jason

Frank ..

my answer has nothing to do with Perl .. but you can also use the standard
Windows copy command to do this

  copy foo.txt + bar.txt c:\temp\baz.txt

that having been said - I don't think that you can combine two PST files by
just concatenating them .. I suspect that they have headers and such - being
a binary file

you will probably have to use Outlook to combine them

-- 
  jason king

  In Norway, you may not spay your female dog or cat.  However, you may
  neuter the males of the species. - http://dumblaws.com/


-Original Message-
From: blowther [mailto:[EMAIL PROTECTED]]
Sent: Fri 20 Apr 2001 09:12
To: 'Peter Scott'; Drain, Frank; Beginners (E-mail)
Subject: RE: cat a file


Something like this will work.

perl -pe "" foo.txt bar.txt  c:\temp\baz.txt


It's disappointing that

perl -p foo.txt bar.txt  c:\temp\baz.txt

doesn't work.  It thinks foo.txt is the perl script to execute.


-Original Message-
From: Peter Scott [mailto:[EMAIL PROTECTED]]
Sent: Thursday, April 19, 2001 2:34 PM
To: Drain, Frank; Beginners (E-mail)
Subject: Re: cat a file


At 04:27 PM 4/19/01 -0400, Drain, Frank wrote:
Hello,

I am very new to perl.  I have two pst (personal folder 
files) that I want
to combine into one.

I know how to use cat in Linux. How do do this
same operation in perl under windows?

# cat.  Usage, e.g.  perl cat .pl file1 file2 file3

while () { print }

--
Peter Scott
Pacific Systems Design Technologies
http://www.perldebugged.com