Re: If anyone doesn't mind helping me optimize this code...

2007-08-23 Thread eselk
Thanks to all who replied. I figured reading (and writing) one byte at a time was the bottleneck, but mostly I'm not familiar with perl's buffer handling functions/methods... I just knew enough to compare one byte at a time at least (and I guess even that wasn't optimal since I was using "eq" inst

Re: If anyone doesn't mind helping me optimize this code...

2007-08-23 Thread John W. Krahn
Rob Dixon wrote: John W. Krahn wrote: In perl you almost *never* need to use the eof() function. That is usually written as: while ( read IN, $buffer, $blksize ) { But even that doesn't report any errors that read() may encounter. while ( my $read = read IN, $buffer, $blksize ) {

Re: If anyone doesn't mind helping me optimize this code...

2007-08-23 Thread Rob Dixon
John W. Krahn wrote: In perl you almost *never* need to use the eof() function. That is usually written as: while ( read IN, $buffer, $blksize ) { But even that doesn't report any errors that read() may encounter. while ( my $read = read IN, $buffer, $blksize ) { defined $read

Re: If anyone doesn't mind helping me optimize this code...

2007-08-22 Thread John W. Krahn
[EMAIL PROTECTED] wrote: I'm a C/C++ programmer, with a perl script I'm trying to optimize. I don't know enough about perl syntax and string/buffer handling functions to feel comfortable doing this on my own. Perl's open()/read() functions are equivalent to C's fopen()/fread() and so the IO i

Re: If anyone doesn't mind helping me optimize this code...

2007-08-22 Thread Mr. Shawn H. Corey
[EMAIL PROTECTED] wrote: $hostname is set to whatever I need to inject by some code above this part, and $search is the data I need to replace with $hostname (they are always the same length, so it never changes the size of the downloaded file). The loop at the end is what I imagine needs to be

If anyone doesn't mind helping me optimize this code...

2007-08-22 Thread eselk
I'm a C/C++ programmer, with a perl script I'm trying to optimize. I don't know enough about perl syntax and string/buffer handling functions to feel comfortable doing this on my own. I imagine adding some 'regular expressions' would be ideal, in place of my while() loop. If anyone wouldn't mind