[22042] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 4264 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Dec 15 00:05:38 2002

Date: Sat, 14 Dec 2002 21:05:07 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Sat, 14 Dec 2002     Volume: 10 Number: 4264

Today's topics:
    Re: Hiya <bart.lateur@pandora.be>
    Re: Hiya <zahm@uiuc.edu>
    Re: Hiya <palladium@spinn.net>
        How to get the HTTP_AUTHORIZE in Perl <tbutler@uninetsolutions.com>
    Re: How to get the HTTP_AUTHORIZE in Perl <bwalton@rochester.rr.com>
    Re: How to get the HTTP_AUTHORIZE in Perl <tbutler@uninetsolutions.com>
        HTTP::Headers <tbutler@uninetsolutions.com>
    Re: HTTP::Headers <mbudash@sonic.net>
    Re: HTTP::Headers <tbutler@uninetsolutions.com>
    Re: HTTP::Headers <mbudash@sonic.net>
    Re: HTTP::Headers <tbutler@uninetsolutions.com>
    Re: Invalid Base64 data msg when sending email <goldbb2@earthlink.net>
        Launch Jobs to a bank of PC (May)
        Need help with caret anchor at start of line <No_Mail_Address@cox.net>
        Odd pack() behavior <brian@gonzo.home>
    Re: open2 program dies <goldbb2@earthlink.net>
        Test::More and overloading "==" (Daniel Berger)
    Re: Test::More and overloading "==" <goldbb2@earthlink.net>
    Re: unix2dos newbie question <vervoom@hotmail.com>
    Re: unix2dos newbie question (Walter Roberson)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Sat, 14 Dec 2002 23:09:20 GMT
From: Bart Lateur <bart.lateur@pandora.be>
Subject: Re: Hiya
Message-Id: <qdenvu4ba3uuch5qfha3p2n63tf3rkdt1d@4ax.com>

Rod wrote:

>> Hey all. I'm a newbie here, and to Perl. Basically, all I really want is a
>> page that will give me a thourough intro to perl, step-by-stpe, and what
>> excactly I need to use Perl. TY a bunch,
>> --
>
>Try
>perl.com
>perl.org
>cpan.org

More specifically, don't forget about 

	<http://learn.perl.org/>

-- 
	Bart.


------------------------------

Date: Sat, 14 Dec 2002 18:52:37 -0600
From: "Robert Zahm" <zahm@uiuc.edu>
Subject: Re: Hiya
Message-Id: <RkQK9.6940$Vf3.73351@vixen.cso.uiuc.edu>

"Anadriel" <bibleboy_101@shaw.ca> wrote in message
news:Y3OK9.165302$ea.3217386@news2.calgary.shaw.ca...
> Hey all. I'm a newbie here, and to Perl. Basically, all I really want is a
> page that will give me a thourough intro to perl, step-by-stpe, and what
> excactly I need to use Perl. TY a bunch,
> --
> Andy

The "Programming Perl" book by O Rielly (the camel book) is pretty good.

Rob




------------------------------

Date: Sat, 14 Dec 2002 18:18:48 -0700
From: "Rod" <palladium@spinn.net>
Subject: Re: Hiya
Message-Id: <uvnm8dm88t55b9@corp.supernews.com>

"Bart Lateur" <bart.lateur@pandora.be> wrote in message
news:qdenvu4ba3uuch5qfha3p2n63tf3rkdt1d@4ax.com...
> Rod wrote:
>
> >> Hey all. I'm a newbie here, and to Perl. Basically, all I really want
is a
> >> page that will give me a thourough intro to perl, step-by-stpe, and
what
> >> excactly I need to use Perl. TY a bunch,
> >> --
> >
> >Try
> >perl.com
> >perl.org
> >cpan.org
>
> More specifically, don't forget about
>
> <http://learn.perl.org/>
>
Yep.. Missed that one specifically.




------------------------------

Date: Sat, 14 Dec 2002 19:38:37 -0600
From: Timothy Butler <tbutler@uninetsolutions.com>
Subject: How to get the HTTP_AUTHORIZE in Perl
Message-Id: <uvnn8tl96hmaf4@corp.supernews.com>

Hi,
  I have a problem. :-) I want to see what password someone has sent in a 
HTTP Authorize password box, and I can't figure out how to do it in Perl. I 
know Apache seems to pass that bit as an encoded string ("HTTP_AUTHORIZE" 
or just "Authorize"). 

  At first I figured it must be impossible to get this data, but then I 
remembered that phpMyAdmin is able to pass the password you type in such a 
box to MySQL - so it *must* be possible. Indeed, PHP lists Authorize as one 
of the headers that is availabe to it. 

  Surely its possible to get this info in Perl too, I assume, isn't it? I 
prefer Perl to PHP by several magnitudes, so I'm dreading the thought of 
having to switch to PHP just to get this info...

  Thanks,
       Tim

-- 
Timothy R. Butler  -  tbutler@uninetsolutions.com 
Universal Networks - http://www.uninet.info
Christian Portal and Search Tool - http://www.faithtree.com
Open Source Migration Guide - http://www.ofb.biz



------------------------------

Date: Sun, 15 Dec 2002 01:45:03 GMT
From: Bob Walton <bwalton@rochester.rr.com>
Subject: Re: How to get the HTTP_AUTHORIZE in Perl
Message-Id: <3DFBDB08.5020407@rochester.rr.com>

Timothy Butler wrote:

 ...

>   I have a problem. :-) I want to see what password someone has sent in a 
> HTTP Authorize password box, and I can't figure out how to do it in Perl. I 
> know Apache seems to pass that bit as an encoded string ("HTTP_AUTHORIZE" 
> or just "Authorize"). 
 ...

>        Tim
 ...

Try looking in $ENV{HTTP_AUTHORIZE}.  Is that the value you want?

-- 
Bob Walton



------------------------------

Date: Sat, 14 Dec 2002 19:47:54 -0600
From: Timothy Butler <tbutler@uninetsolutions.com>
Subject: Re: How to get the HTTP_AUTHORIZE in Perl
Message-Id: <uvnnqalumvbud7@corp.supernews.com>

Hi Bob,
> Try looking in $ENV{HTTP_AUTHORIZE}.  Is that the value you want?

  Not exactly. I think that is the right env name, but it returns an empty 
string. :-(

  Thanks,
       Tim


-- 
Timothy R. Butler  -  tbutler@uninetsolutions.com 
Universal Networks - http://www.uninet.info
Christian Portal and Search Tool - http://www.faithtree.com
Open Source Migration Guide - http://www.ofb.biz



------------------------------

Date: Sat, 14 Dec 2002 19:52:16 -0600
From: Timothy Butler <tbutler@uninetsolutions.com>
Subject: HTTP::Headers
Message-Id: <uvno2g6jdr7h3a@corp.supernews.com>

On a similar note, it looks like the HTTP::Headers library should return 
information like what I'm looking for. I thought to test that function, I 
would try a header I *knew* should exist (user_agent)... but even that 
comes up blank. Does this code:

$h = HTTP::Headers->new;
@data = $h->user_agent;


  ...look like it should be returning user_agent to the @data array? 

  Thanks,
       Tim

-- 
Timothy R. Butler  -  tbutler@uninetsolutions.com 
Universal Networks - http://www.uninet.info
Christian Portal and Search Tool - http://www.faithtree.com
Open Source Migration Guide - http://www.ofb.biz



------------------------------

Date: Sun, 15 Dec 2002 02:55:16 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: HTTP::Headers
Message-Id: <mbudash-61F479.18551514122002@typhoon.sonic.net>

In article <uvno2g6jdr7h3a@corp.supernews.com>,
 Timothy Butler <tbutler@uninetsolutions.com> wrote:

> On a similar note, it looks like the HTTP::Headers library should return 
> information like what I'm looking for. I thought to test that function, I 
> would try a header I *knew* should exist (user_agent)... but even that 
> comes up blank. Does this code:
> 
> $h = HTTP::Headers->new;
> @data = $h->user_agent;
> 
> 
>   ...look like it should be returning user_agent to the @data array? 
> 
>   Thanks,
>        Tim

nope. you just created a new HTPP::Header object in the line above, so 
there's nothing in the user_agent yet...

in what context is this script running? if cgi, the HTTP_USER_AGENT 
environment variable will contain the value, if any (it can easily be 
faked):

$ENV{HTTP_USER_AGENT}

hth-


------------------------------

Date: Sat, 14 Dec 2002 21:41:40 -0600
From: Timothy Butler <tbutler@uninetsolutions.com>
Subject: Re: HTTP::Headers
Message-Id: <uvnufkmv6oe5fd@corp.supernews.com>

 
> nope. you just created a new HTPP::Header object in the line above, so
> there's nothing in the user_agent yet...

  How can I grab the header of the HTTP session that just invoked the script 
rather than creating a new one?

> in what context is this script running? if cgi, the HTTP_USER_AGENT
> environment variable will contain the value, if any (it can easily be
> faked):

  That's true, the main reason I was trying USER_AGENT was that I knew it 
should be set. Once I got that working through this method, I figured I 
might have a chance at getting what I *really* wanted: authorization_basic 
 .

  Thanks,
       Tim

-- 
Timothy R. Butler  -  tbutler@uninetsolutions.com 
Universal Networks - http://www.uninet.info
Christian Portal and Search Tool - http://www.faithtree.com
Open Source Migration Guide - http://www.ofb.biz



------------------------------

Date: Sun, 15 Dec 2002 04:43:24 GMT
From: Michael Budash <mbudash@sonic.net>
Subject: Re: HTTP::Headers
Message-Id: <mbudash-22D1F2.20432314122002@typhoon.sonic.net>

In article <uvnufkmv6oe5fd@corp.supernews.com>,
 Timothy Butler <tbutler@uninetsolutions.com> wrote:

>  
> > nope. you just created a new HTPP::Header object in the line above, so
> > there's nothing in the user_agent yet...
> 
>   How can I grab the header of the HTTP session that just invoked the script 
> rather than creating a new one?

as i said below...

> > in what context is this script running? if cgi, the HTTP_USER_AGENT
> > environment variable will contain the value, if any (it can easily be
> > faked):
> 
>   That's true, the main reason I was trying USER_AGENT was that I knew it 
> should be set. 

it might be if you were *passed* an HTTP::Header object, but you're not 
in a cgi environment...

> Once I got that working through this method, I figured I 
> might have a chance at getting what I *really* wanted: authorization_basic

once again, if cgi, the HTTP_REMOTE_USER environment variable will 
contain the value of the user authorized via basic authentication, if 
any. the password cannot be gotten this way (for obvious security 
reasons)

hth-


------------------------------

Date: Sat, 14 Dec 2002 22:48:52 -0600
From: Timothy Butler <tbutler@uninetsolutions.com>
Subject: Re: HTTP::Headers
Message-Id: <uvo2dl2362st46@corp.supernews.com>


> it might be if you were *passed* an HTTP::Header object, but you're not
> in a cgi environment...

  Hmm... would it make a difference if mod_perl was running, I guess? Any 
ideas on how might I circumvent that?
 
>> Once I got that working through this method, I figured I
>> might have a chance at getting what I *really* wanted:
>> authorization_basic
> 
> once again, if cgi, the HTTP_REMOTE_USER environment variable will
> contain the value of the user authorized via basic authentication, if
> any. the password cannot be gotten this way (for obvious security
> reasons)

  Well HTTP_REMOTE_USER does return the user, but also need the password... 
that's where the trouble begins. What I need seems to be the 
"HTTP_AUTHORIZE" field, which incidentally is empty. I know php receives 
this information, so I'm just trying to figure out how to get it in Perl.

  Thanks,
       Tim 

-- 
Timothy R. Butler  -  tbutler@uninetsolutions.com 
Universal Networks - http://www.uninet.info
Christian Portal and Search Tool - http://www.faithtree.com
Open Source Migration Guide - http://www.ofb.biz



------------------------------

Date: Sat, 14 Dec 2002 23:55:12 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Invalid Base64 data msg when sending email
Message-Id: <3DFC0B30.15C014CE@earthlink.net>

bpaluch wrote:
> 
> I am trying to use perl to send email through a server which requires
> authentication. (This is my own account, this is not spam).
> 
> The code is below.
> 
>         $smtp->command("AUTH", "LOGIN");
>         $smtp->command(MIME::Base64::encode_base64("username@myserver.com"));
>         $smtp->command(MIME::Base64::encode_base64("mypass"));
> 
>         $smtp->mail($from);
[snip]
> Net::SMTP=GLOB(0x2d7353c)>>> AUTH LOGIN
> Net::SMTP=GLOB(0x2d7353c)>>> [base64 encoded username]
> Net::SMTP=GLOB(0x2d7353c)>>> [base64 encoded password]
> Net::SMTP=GLOB(0x2d7353c)>>> MAIL FROM:
> Net::SMTP=GLOB(0x2d7353c)<<< 334 VXNlcm5hbWU6
> Net::SMTP=GLOB(0x2d7353c)>>> RCPT TO:
> Net::SMTP=GLOB(0x2d7353c)<<< 501 Invalid base64 data

It looks like your responses are out of synch with your commands.

Try:

   for my $auth (
      [qw/AUTH LOGIN/], map [MIME::Base64::encode_base64($_)],
      "username@myserver.com", "mypass"
   ) {
      $smtp->command(@$auth);
      $smtp->response;
      die $smtp->message unless $smtp->ok;
   }

   $smtp->mail($from);

Or, if you have Authen::SASL installed on your machine, you can do:

   $smtp->auth("username@myserver.com", "mypass");
   $smtp->mail($from);

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


------------------------------

Date: 14 Dec 2002 20:57:30 -0800
From: hmtan@hotmail.com (May)
Subject: Launch Jobs to a bank of PC
Message-Id: <1c5e0a53.0212142057.4b07f7aa@posting.google.com>

Hi,
   I would like to launch job to a bank on PC on windows NT but not
sure how.
Currently I launch my job from 1PC by the command prompt as > perl
call_eda.pl and copy the perl scripts into the rest of the PC and
launch the same jobs. I wonder perl have something like the lsf ?

thanks
May


------------------------------

Date: Sun, 15 Dec 2002 03:32:43 GMT
From: Fred <No_Mail_Address@cox.net>
Subject: Need help with caret anchor at start of line
Message-Id: <3DFBF864.7E002359@cox.net>


I have the following text in a file (simulating a message header):

To: <juergen@aol.com>
CC: <mail@home.com>, <philipp@partners.net>, <Michael@online.com>,
     <david@msn.com>, <job555@aol.com>, <siang@hotmail.com>
X-Mozilla-Status: 8001

I want to convert the text to:

<juergen@aol.com>
<mail@home.com>
<philipp@partners.net>
<Michael@online.com>
X-Mozilla-Status: 8001

I use the following while loop, which does what I want:

while (<>) {
   s/[, ]*$//g ;				# remove commas or spaces at EOL
   s/^[ \t]+(.+\n)/To: $1/i ;		# convert starting space into To:
   s/(.+?\@.+?), (.+?\@.+?)/$1\nTo: $2/ ;		# split multiple addresses
   s/(.+?\@.+?), (.+?\@.+?)/$1\nTo: $2/ ;		# split multiple addresses
   s/(?:To:|CC:)\s*//ig ;	
   next if (m/(?:<job|<siang)/) ;	
   print OUT $_ ;		
}

But I do not understand why the code is not working when I use a caret
as "beginning of the line" anchor in the last two lines:

while (<>) {
   s/[, ]*$//g ;				# remove commas or spaces at EOL
   s/^[ \t]+(.+\n)/To: $1/i ;		# convert starting space into To:
   s/(.+?\@.+?), (.+?\@.+?)/$1\nTo: $2/ ;		# split multiple addresses
   s/(.+?\@.+?), (.+?\@.+?)/$1\nTo: $2/ ;		# split multiple addresses
   s/^(?:To:|CC:)\s*//ig ;		# Remove TO: and cc: at start of line
   next if (m/^(?:<job|<siang)/) ;	
   print OUT $_ ;		
}

Can anyone please explain me the reason?
----
Fred


------------------------------

Date: Sun, 15 Dec 2002 04:24:28 -0000
From: "Brian C. Lane" <brian@gonzo.home>
Subject: Odd pack() behavior
Message-Id: <slrnavo0rp.kkg.brian@gonzo.home>

I've run into a strange problem with pack. It seems to be outputting a
single byte for 'H2' on one machine, which is the correct behavior. But on
another maching I'm getting 2 bytes, and they aren't what they are supposed
to be.

uname -a on the machine that works right is
Linux rush 2.2.19 #1 Thu Nov 1 19:52:06 EST 2001 i586 unknown

perl --version is 
This is perl, version 5.005_03 built for i386-linux


uname -a on the machine that doesn't work is
Linux gonzo.home 2.4.18-4acpi #11 Mon Dec 9 19:56:48 PST 2002 i686 athlon
i386 GNU/Linux

And perl --version is
This is perl, v5.8.0 built for i386-linux-thread-multi


Here's the program:

#!/usr/bin/perl

# input file, output file, number of bytes to pad,
sub pad_file {
    my ($output, $num_bytes) = @_;
    my $char = pack "H2", "ff";

    open(output_fh, ">>$output");

    # add the byte padding
    while ($num_bytes > 0) { print output_fh $char; $num_bytes--; }

    close(output_fh);
    return;
}

pad_file( "./testpad", 10 );


Thanks for any help,

Brian


-- 
 --[Inside 71.6F]--[Outside 49.9F]--[fozzy 68.7F]--[Drink 64.1F]--
Generated with DigiTemp http://www.digitemp.com


------------------------------

Date: Sat, 14 Dec 2002 23:10:10 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: open2 program dies
Message-Id: <3DFC00A2.2111D57D@earthlink.net>

Brad wrote:
> Benjamin Goldberg wrote:
> > Garry Williams wrote:
> > > Mike Wilson wrote:
> > [snipped stuff: when writing to pipe that sends to stdin of child
> > process, the parent process is killed if the child process exits]
> > >
> > > You probably want to catch SIGPIPE.  See perlcar and look at the
> > > %SIG entry.
> > >
> > > For example:
> > >
> > >   $SIG{PIPE} = sub {
> > >       warn "child seems to have exited...";
> > >       $child_exited = 1;
> > >   };
> > >
> > > Or maybe you will read the child's stdout and get end of file
> > > eventually.  In that case, you may want to ignore SIGPIPE and rely
> > > on EOF:
> > >
> > >   $SIG{PIPE} = 'IGNORE';
> >
> Actually, on Unix anyway, the best way to know if a child has died is
> to catch the SIGCHLD signal.  I believe a SIGCHLD will be issued prior
> to any other SIGNAL due to a child's death.

Sure, but what happens if you recieve the SIGCHLD signal while you're in
the midst of a print() statement?  Keep in mind, on pre-5.8 perls,
signals are not safe.

It's simply *safer* to have $SIG{CHLD} be set to 'DEFAULT', and set
$SIG{PIPE} to IGNORE, and detect death of the child process either from
an EPIPE when writinging, or an EOF when reading, and after the child is
known to be dead, call waitpid() on it's pid.  Hmm, and more portable,
too, I suspect.

-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


------------------------------

Date: 14 Dec 2002 18:21:23 -0800
From: djberg96@hotmail.com (Daniel Berger)
Subject: Test::More and overloading "=="
Message-Id: <6e613a32.0212141821.4a7c6d87@posting.google.com>

Hi all,

Perl 5.8 on Mandrake 9

While using Test::More, I came across a problem trying to test an
overloaded operator.  I have a class and created a "=="  instance
method using "overload", ala:

use overload
   "==" => is_equal,
   "fallback" => 1;

The is_equal method simply returns 0 if false, 1 if true.

While trying to test, I did:

ok($obj1 == $obj2);

This caused problems as I get this error:

Can't find string terminator "/" anywhere before EOF

I also tried is(), and grabbing the return value first, then testing
against the return value:

my $rv = ($obj1 == $obj2);
ok($rv,1);

But I got the same result.

Is there a proper way to test an overloaded operator like this?  Have
I missed something in the docs?

Regards,

Dan


------------------------------

Date: Sat, 14 Dec 2002 23:35:29 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: Test::More and overloading "=="
Message-Id: <3DFC0691.33047630@earthlink.net>

Daniel Berger wrote:
> 
> Hi all,
> 
> Perl 5.8 on Mandrake 9
> 
> While using Test::More, I came across a problem trying to test an
> overloaded operator.  I have a class and created a "=="  instance
> method using "overload", ala:
> 
> use overload
>    "==" => is_equal,
>    "fallback" => 1;
> 
> The is_equal method simply returns 0 if false, 1 if true.
> 
> While trying to test, I did:
> 
> ok($obj1 == $obj2);
> 
> This caused problems as I get this error:
> 
> Can't find string terminator "/" anywhere before EOF

Where did it say that this error occured?

It looks like something that is, or should be, a compile time error.

Could you give a minimal perl script which demonstrates this problem?


-- 
$..='(?:(?{local$^C=$^C|'.(1<<$_).'})|)'for+a..4;
$..='(?{print+substr"\n !,$^C,1 if $^C<26})(?!)';
$.=~s'!'haktrsreltanPJ,r  coeueh"';BEGIN{${"\cH"}
|=(1<<21)}""=~$.;qw(Just another Perl hacker,\n);


------------------------------

Date: Sat, 14 Dec 2002 23:03:32 -0800
From: "Edward Quick" <vervoom@hotmail.com>
Subject: Re: unix2dos newbie question
Message-Id: <atgdkh$or6$1@cspc1n11.baplc.com>


pkent <pkent77tea@yahoo.com.tea> wrote in message
news:pkent77tea-FDDA12.01221714122002@news-text.blueyonder.co.uk...
> In article <slrnavi713.48l.tadmc@magna.augustmail.com>,
>  tadmc@augustmail.com (Tad McClellan) wrote:
>
> > Edward Quick <vervoom@hotmail.com> wrote:
> > > I need to perform a unix2dos function on $ftpbuf,
> > > but I'm not too sure how to do this in Perl.
> >
> > If your Perl program is running on Unix:
> >
> >    $ftpbuf =~ s/\n/\r\n/g;
>
> And as we know what code points are used for the line ending sequences
> on DOS and Unix, what's wrong with:
>
> $ftpbuf =~ s/\x0A/\x0D\x0A/g;
> # I really hope those are the right way round.
>
> and that will work on any OS, converting Unix line endings to DOS line
> endings. Problem is that it _assumes_ your input really does have Unix
> line endings but maybe that's covered elsewhere in the thread.
>
> P
>
> --
> pkent 77 at yahoo dot, er... what's the last bit, oh yes, com
> Remove the tea to reply

Thanks for the replies. Assuming I use $ftpbuf =~ s/\n/\r\n/g;
then when I do syswrite, the number of bytes written won't be the same as
the number of bytes read. I have this routine :

while( ($len = sysread( FH, $ftpbuf, $ftpbufsize )) > 0 ){
               $ftpbuf =~ s/\n/\r\n/g;
               $bytes_read += $len;

                while( ($len2 = &write( NS, $ftpbuf, $left )) > 0 ){
                        $bytes_written+= $len2;
                }
}

I want to check what I've read gets written though so I tried:
                $bytes_read += length($ftpbuf);
expecting $bytes_read to be equal to $bytes_written. However I got:

len = 4096     length(ftpbuf) = 4225     bytes_read = 4225
len2 = 4096                                        byteswritten = 4096
len = 2771     length(ftpbuf) = 2850     bytes_read = 7075
len2 = 2850                                        byteswritten = 6946
number of bytes written not equal to number read

How come the bytes written are less than bytes_read when I use
length(ftpbuf)?

Ed.




------------------------------

Date: 15 Dec 2002 01:18:08 GMT
From: roberson@ibd.nrc.ca (Walter Roberson)
Subject: Re: unix2dos newbie question
Message-Id: <atgl8g$6pg$1@canopus.cc.umanitoba.ca>

In article <atgdkh$or6$1@cspc1n11.baplc.com>,
Edward Quick <vervoom@hotmail.com> wrote:
:then when I do syswrite, the number of bytes written won't be the same as
:the number of bytes read.

perl's syswrite uses the underlying system's write(2) call, so you
have to read the description of that to understand what's going on.

Generally speaking, if you are writing to a true file and the
filesystem doesn't fill up and you don't hit quotas, and so on, then
write(2) will usually write the entire buffer. If, however, you are
writing to something other than a true file, there are usually limits
on how much data is certain to be written in one go. The POSIX
requirement on pipe buffer sizes is only 512 bytes.
--
Can a statement be self-referential without knowing it?


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

The Perl-Users Digest is a retransmission of the USENET newsgroup
comp.lang.perl.misc.  For subscription or unsubscription requests, send
the single line:

	subscribe perl-users
or:
	unsubscribe perl-users

to almanac@ruby.oce.orst.edu.  

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

To request back copies (available for a week or so), send your request
to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
where x is the volume number and y is the issue number.

For other requests pertaining to the digest, send mail to
perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
sending perl questions to the -request address, I don't have time to
answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 4264
***************************************


home help back first fref pref prev next nref lref last post