[31214] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2459 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu Jun 4 21:09:48 2009

Date: Thu, 4 Jun 2009 18:09:13 -0700 (PDT)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Thu, 4 Jun 2009     Volume: 11 Number: 2459

Today's topics:
        $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}} jidanni@jidanni.org
    Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}} sln@netherlands.com
    Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}} sln@netherlands.com
    Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}} <jimsgibson@gmail.com>
    Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}} <1usa@llenroc.ude.invalid>
    Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}} (Alan Curry)
    Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}} <nospam-abuse@ilyaz.org>
    Re: Flash calling Php calling Perl <marksmith5555@jungle-monkey.com>
    Re: Flash calling Php calling Perl <ben@morrow.me.uk>
        PDF::Create - text colour <usenet05@drabble.me.uk>
    Re: PDF::Create - text colour <smallpond@juno.com>
    Re: Perl FTP Get Help <nat.k@gm.ml>
    Re: print buffer in Perl 5.10 <jimsgibson@gmail.com>
    Re: print buffer in Perl 5.10 <john1949@yahoo.com>
    Re: print buffer in Perl 5.10 <jimsgibson@gmail.com>
    Re: print buffer in Perl 5.10 <ben@morrow.me.uk>
    Re: print buffer in Perl 5.10 <hjp-usenet2@hjp.at>
    Re: Update <cwilbur@chromatico.net>
    Re: What happened to perl doc <1usa@llenroc.ude.invalid>
    Re: What happened to perl doc <klausfpga@gmail.com>
    Re: What happened to perl doc <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Fri, 05 Jun 2009 04:09:30 +0800
From: jidanni@jidanni.org
Subject: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
Message-Id: <87ab4ndamd.fsf@jidanni.org>

Can one blame the user if he can do
push @{$h{$_}}, 44;
but has a hard time guessing that only the final one of
$#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
will tell him how many elements are in the array where he pushed it?


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

Date: Thu, 04 Jun 2009 14:35:51 -0700
From: sln@netherlands.com
Subject: Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
Message-Id: <r6fg25d9vr3af7fo0s833hre1gmg8udfkj@4ax.com>

On Fri, 05 Jun 2009 04:09:30 +0800, jidanni@jidanni.org wrote:

>Can one blame the user if he can do
>push @{$h{$_}}, 44;
>but has a hard time guessing that only the final one of
>$#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
>will tell him how many elements are in the array where he pushed it?

Not at all.

$#   @{   $h{$_}   }

$h{$_} if correct is a sclar reference to an array.
@{} dereferences the context, assuming a ref to an array.
$# now knows where to look to get the size.

-sln


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

Date: Thu, 04 Jun 2009 14:39:38 -0700
From: sln@netherlands.com
Subject: Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
Message-Id: <rlfg25hde3bf9iv4h5mav7pngtjfisg6ho@4ax.com>

On Thu, 04 Jun 2009 14:35:51 -0700, sln@netherlands.com wrote:

>On Fri, 05 Jun 2009 04:09:30 +0800, jidanni@jidanni.org wrote:
>
>>Can one blame the user if he can do
>>push @{$h{$_}}, 44;
>>but has a hard time guessing that only the final one of
>>$#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
>>will tell him how many elements are in the array where he pushed it?
>
>Not at all.
>
>$#   @{   $h{$_}   }
>
>$h{$_} if correct is a sclar reference to an array.
>@{} dereferences the context, assuming a ref to an array.
>$# now knows where to look to get the size.
>
>-sln

no less complicated than this:

my $self = {};
$self->{'vstr'} = [\(('hi ')x10)];
print "$$_ " for @{$self->{'vstr'}};


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

Date: Thu, 04 Jun 2009 14:56:46 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
Message-Id: <040620091456464668%jimsgibson@gmail.com>

In article <87ab4ndamd.fsf@jidanni.org>, <jidanni@jidanni.org> wrote:

> Can one blame the user if he can do
> push @{$h{$_}}, 44;
> but has a hard time guessing that only the final one of
> $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
> will tell him how many elements are in the array where he pushed it?

Yes. None of those will tell him how many elements are in the array.
Only the first is valid Perl, and gives the "highest index", which is
normally one less than the number of elements in the array.

The second gives me "Can't use string ("1") as an ARRAY ref while
"strict refs" in use at jidanni.pl line 12.", because an array
evaluated in scalar context returns the number of elements in the
array, and my test array had one element. (However, I just tried "perl
-Mstrict -e 'print $#{'1'};'", and that doesn't give me an error, so
maybe there is some other reason for the error.)

The third won't even compile:

"$# is no longer supported at jidanni.pl line 13.
Array found where operator expected at jidanni.pl line 13, at end of
line
        (Missing operator before ?)
Can't use an undefined value as a symbol reference at jidanni.pl line
13."

Test program:

#!/usr/local/bin/perl
use strict;
use warnings;

my %h;
$_ = 'A';
$h{$_} = [];

push( @{$h{$_}}, 44 );

print $#{$h{$_}};
print $#{@{$h{$_}}};  # Can't use string ("1") as an ARRAY ref ...
print $#@{$h{$_}};  # no longer supported ...


There is no need to guess. The rule is that if @{X} is an array, then
$#{X} is the highest index of the array. 'X' can be a bare-word array
name or an array reference. If the former, then the braces {} are
optional. If X is a simple variable, e.g. $x, then the braces are also
optional.

-- 
Jim Gibson


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

Date: Thu, 04 Jun 2009 22:11:27 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
Message-Id: <Xns9C20B915CF257asu1cornelledu@127.0.0.1>

jidanni@jidanni.org wrote in news:87ab4ndamd.fsf@jidanni.org:

> Can one blame the user if he can do
> push @{$h{$_}}, 44;
> but has a hard time guessing that only the final one of
> $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
> will tell him how many elements are in the array where he pushed it?

First, a little whitespace will tell you which one of those makes sense.

But more importantly, why does the said user not use the array in scalar 
context to get the number of elements in the array?

#!/usr/bin/perl

use strict;
use warnings;

my %h;

push @{ $h{test} }, 44;

print scalar @{ $h{test} }, "\n";

__END__


-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Thu, 4 Jun 2009 22:54:55 +0000 (UTC)
From: pacman@kosh.dhis.org (Alan Curry)
Subject: Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
Message-Id: <h09jbv$9em$1@aioe.org>

In article <040620091456464668%jimsgibson@gmail.com>,
Jim Gibson  <jimsgibson@gmail.com> wrote:
[...]
>array, and my test array had one element. (However, I just tried "perl
>-Mstrict -e 'print $#{'1'};'", and that doesn't give me an error, so
>maybe there is some other reason for the error.)

Because the 1 is not in quotes by the time perl gets it. Your -e program is
assembled by the shell from the 2 separate ''-delimited strings and the
unquoted 1 that's in between them. The code as perl sees it:

  print $#{1}

is related to the array named "@1" which, since its name starts with a digit,
is exempt from the effects of your -Mstrict.

$ perl -Mstrict -e 'print $#{'1'}'
-1
$ perl -Mstrict -e 'print $#{"1"}'
Can't use string ("1") as an ARRAY ref while "strict refs" in use at -e line 1.

-- 
Alan Curry


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

Date: Thu, 04 Jun 2009 23:32:19 GMT
From: Ilya Zakharevich <nospam-abuse@ilyaz.org>
Subject: Re: $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
Message-Id: <slrnh2gmjh.kdq.nospam-abuse@chorin.math.berkeley.edu>

On 2009-06-04, jidanni@jidanni.org <jidanni@jidanni.org> wrote:
> Can one blame the user if he can do
> push @{$h{$_}}, 44;
> but has a hard time guessing that only the final one of
> $#{$h{$_}}, $#{@{$h{$_}}}, $#@{$h{$_}}
> will tell him how many elements are in the array where he pushed it?

It is very hard to understand what are you talking about; too many
wrong substatements...

 >perl -wle "$h{a}=[1..8]; print $#{$h{a}}"
 7

Puzzled,
Ilya


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

Date: Thu, 4 Jun 2009 08:32:45 -0700 (PDT)
From: Mark Smith <marksmith5555@jungle-monkey.com>
Subject: Re: Flash calling Php calling Perl
Message-Id: <332c50a2-6ef3-447b-ad6d-b3760a03ba5d@t10g2000vbg.googlegroups.com>

On Jun 4, 11:28=A0am, Bill H <b...@ts1000.us> wrote:
> Background:
>
> I have a flash program that posts user enter data to a php program on
> the server.
> The php program then saves this data in a database and then uses system
> () to call the perl program which takes the data and generates a pdf
> file and thumbnail images.
> The php program, on completion of the perl program then sends a status
> back to flash telling it was done. Flash then calls the php script to
> get thes thumbnails for the view to see. This process can take 10 or
> more seconds on the perl side to complete.
>
> We are changing the flash aplication so that there is no need for it
> to display the thumbnails after posting the data over and I am looking
> for a way of having the php program just start the perl program but
> not wait for it to complete before sending back the status to flash.
>
> From all the possible PHP commands, exec(), shell_exec(), passthru()
> and system(), it seems that they all wait for the called program to
> finish, is there a way to just start the program and not wait for it
> to complete?
>
> The other method would be to send the results back to flash prior to
> calling the perl program and not care how long perl took to do its
> job. Would flush() and ob_flush() be sufficient to force this
> information out to flash (the only information being sent back is
> "result=3Dsaved" or "result=3Dfail")?
>
> If this is not possible, then on the perl side (crossposted to
> comp.lang.perl.misc for this question), is there a way of having a
> script take the command line arguments passed by php's shell() and
> forking (is this right term?) the real perl program and ending so that
> php is not waiting for the real program to finish?
>
> Bill H

If it was me, unless your perl script is doing something really
special I'd do it all in php:

http://www.fpdf.org/


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

Date: Thu, 4 Jun 2009 23:19:57 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Flash calling Php calling Perl
Message-Id: <dttlf6-ei2.ln1@osiris.mauzo.dyndns.org>

[f'ups set to c.l.perl.misc]

Quoth Bill H <bill@ts1000.us>:
> 
> If this is not possible, then on the perl side (crossposted to
> comp.lang.perl.misc for this question), is there a way of having a
> script take the command line arguments passed by php's shell() and
> forking (is this right term?) the real perl program and ending so that
> php is not waiting for the real program to finish?

The simplest way of doing this (assuming a Unix system, or some other
system with a real fork(2)) would be to have

    fork and exit;

as the first 'real' statement in your Perl program. You would probably
want to add error checking, of course. See perldoc perlipc.

Ben



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

Date: Thu, 04 Jun 2009 22:30:36 +0100
From: Graham Drabble <usenet05@drabble.me.uk>
Subject: PDF::Create - text colour
Message-Id: <Xns9C20E4FC3982Fgrahamdrabblelineone@ID-77355.user.dfncis.de>

Hi all,

I've been asked to modify a bunch of Perl scripts that use PDF::Create 
to generate PDF documents. Currently all the text is in black and I 
need to be able to change the colour of some of it.

Is this possible using PDF::Create? I can't see anything in the docs. 
Alternatively what would people recommend using?

-- 
Graham Drabble
http://www.drabble.me.uk/


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

Date: Thu, 4 Jun 2009 15:42:20 -0700 (PDT)
From: smallpond <smallpond@juno.com>
Subject: Re: PDF::Create - text colour
Message-Id: <1b290a99-80f8-4a28-b52a-23a81c2c1b32@r34g2000vba.googlegroups.com>

On Jun 4, 5:30=A0pm, Graham Drabble <usene...@drabble.me.uk> wrote:
> Hi all,
>
> I've been asked to modify a bunch of Perl scripts that use PDF::Create
> to generate PDF documents. Currently all the text is in black and I
> need to be able to change the colour of some of it.
>
> Is this possible using PDF::Create? I can't see anything in the docs.

Look harder:

setrgbcolor r g b
Set the color of the subsequent drawing operations. R,G and B is a
value between 0.0 and 1.0.


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

Date: Thu, 04 Jun 2009 14:00:26 -0700
From: Nathan Keel <nat.k@gm.ml>
Subject: Re: Perl FTP Get Help
Message-Id: <KBWVl.1375$ke5.214@newsfe18.iad>

mparker@ygptech.com wrote:

> I posted all of my code below for easy reference. I have this code
> setup to connect to an FTP server and download some files. It works
> great when I login as root. However, when I run this in cron I get the
> error below. I set the directory permissions to 0777 just to see if it
> would work and I get the same error.
> 
> Does anyone have any thoughts or any recommendations on what I can
> look at to begin troubleshooting?
> 
> Thanks in advance!
> 
> Errors:
> Cannot open Local file agents.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 12
> Cannot open Local file commercial.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 13
> Cannot open Local file condominium.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 14
> Cannot open Local file multifamily.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 15
> Cannot open Local file offices.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 16
> Cannot open Local file residential.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 17
> Cannot open Local file vacantland.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 18
> Cannot open Local file photos.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 26
> Cannot open Local file openhouse.txt: Permission denied
> at /var/www/vhosts/domain.com/httpdocs/realcomp/idx.pl line 34


Check the permissions/ownerships of the directory itself, but also the
parent directory, as well as the file if it already exists.


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

Date: Thu, 04 Jun 2009 09:19:28 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: print buffer in Perl 5.10
Message-Id: <040620090919280377%jimsgibson@gmail.com>

In article <h0850t$q2j$1@news.albasani.net>, John <john1949@yahoo.com>
wrote:

> "Ben Morrow" <ben@morrow.me.uk> wrote in message 
> news:s6kif6-ir2.ln1@osiris.mauzo.dyndns.org...
> >
> > Quoth "John" <john1949@yahoo.com>:
> >>
> >> Moved from Etch to Lenny in Debian and from Perl 5.8.8 to 5.10.
> >>
> >> Normally I use:
> >> our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard output
> >> socket hot
> >> but this appears no longer to work and output is now buffered.
> >
> > That construction (ugly as it may be) ought to still work in 5.10.
> > Please post a complete, short script that we can run which demonstrates
> > your problem.
> >
> > Ben
> >
> 
> The proram is embarrassingly small but I cannot stop the print buffer.

What do you mean by "stop the print buffer"?

> 
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> # use FileHandle; STDOUT->autoflush(1);
> our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard output 
> socket hot
> 
> print "Content-type: text/html\n\n";
> 
> print "hallo\n";
> print "hallo<br>\n";
> sleep(5);
> print "hallo<br>\n";
> sleep(5);
> print "hallo<br>";
> sleep(10);
> print "hallo<br>";
> sleep(2);

The program can be made even smaller and still demonstrate the
condition (I hesitate to call it a "problem" as I do not know what the
problem is.)

#!/usr/local/bin/perl
use strict;
use warnings;
our $old_fh=select(STDOUT); $|=1; select($old_fh);  #line 4
for my $n ( 1..5 ) {
  print "Line $n "; # line 6
  sleep(2);
}
print "\n";

Note that if you replace line 6 with:
  print "Line $n\n";
on my system (Mac OS 10.5.7, Perl 5.10.0), the newline character forces
a flush regardless of the autoflush setting on STDOUT. You need to run
the program as shown above with and without line 4 to see the
difference.

Your program looks like a CGI program. Are you trying to run it from a
command-line or from a browser? That will certainly affect your
expected results.

Please explain in more detail the problem you are trying to solve.

Thanks.

-- 
Jim Gibson


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

Date: Thu, 4 Jun 2009 17:26:35 +0100
From: "John" <john1949@yahoo.com>
Subject: Re: print buffer in Perl 5.10
Message-Id: <h08sjh$rgb$1@news.albasani.net>


"Jim Gibson" <jimsgibson@gmail.com> wrote in message 
news:040620090919280377%jimsgibson@gmail.com...
> In article <h0850t$q2j$1@news.albasani.net>, John <john1949@yahoo.com>
> wrote:
>
>> "Ben Morrow" <ben@morrow.me.uk> wrote in message
>> news:s6kif6-ir2.ln1@osiris.mauzo.dyndns.org...
>> >
>> > Quoth "John" <john1949@yahoo.com>:
>> >>
>> >> Moved from Etch to Lenny in Debian and from Perl 5.8.8 to 5.10.
>> >>
>> >> Normally I use:
>> >> our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard 
>> >> output
>> >> socket hot
>> >> but this appears no longer to work and output is now buffered.
>> >
>> > That construction (ugly as it may be) ought to still work in 5.10.
>> > Please post a complete, short script that we can run which demonstrates
>> > your problem.
>> >
>> > Ben
>> >
>>
>> The proram is embarrassingly small but I cannot stop the print buffer.
>
> What do you mean by "stop the print buffer"?
>
>>
>> #!/usr/bin/perl
>> use strict;
>> use warnings;
>>
>> # use FileHandle; STDOUT->autoflush(1);
>> our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard output
>> socket hot
>>
>> print "Content-type: text/html\n\n";
>>
>> print "hallo\n";
>> print "hallo<br>\n";
>> sleep(5);
>> print "hallo<br>\n";
>> sleep(5);
>> print "hallo<br>";
>> sleep(10);
>> print "hallo<br>";
>> sleep(2);
>
> The program can be made even smaller and still demonstrate the
> condition (I hesitate to call it a "problem" as I do not know what the
> problem is.)
>
> #!/usr/local/bin/perl
> use strict;
> use warnings;
> our $old_fh=select(STDOUT); $|=1; select($old_fh);  #line 4
> for my $n ( 1..5 ) {
>  print "Line $n "; # line 6
>  sleep(2);
> }
> print "\n";
>
> Note that if you replace line 6 with:
>  print "Line $n\n";
> on my system (Mac OS 10.5.7, Perl 5.10.0), the newline character forces
> a flush regardless of the autoflush setting on STDOUT. You need to run
> the program as shown above with and without line 4 to see the
> difference.
>
> Your program looks like a CGI program. Are you trying to run it from a
> command-line or from a browser? That will certainly affect your
> expected results.
>
> Please explain in more detail the problem you are trying to solve.
>
> Thanks.
>
> -- 
> Jim Gibson

Yes it is run from a browser.

Since autoflush has  been set then each line should be printed immediately 
followed by a wait of so many seconds.

At present, all the output is buffered and then printed at one go.

At the weekend we upgraded the server from Debian Etch to Debian Lenny, and 
from Perl 5.8.8 to Perl 5.10.

Previously the autoflush was working.

Regards
John





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

Date: Thu, 04 Jun 2009 12:25:34 -0700
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: print buffer in Perl 5.10
Message-Id: <040620091225346654%jimsgibson@gmail.com>

In article <h08sjh$rgb$1@news.albasani.net>, John <john1949@yahoo.com>
wrote:

> "Jim Gibson" <jimsgibson@gmail.com> wrote in message 
> news:040620090919280377%jimsgibson@gmail.com...
> > In article <h0850t$q2j$1@news.albasani.net>, John <john1949@yahoo.com>
> > wrote:
> >

> > #!/usr/local/bin/perl
> > use strict;
> > use warnings;
> > our $old_fh=select(STDOUT); $|=1; select($old_fh);  #line 4
> > for my $n ( 1..5 ) {
> >  print "Line $n "; # line 6
> >  sleep(2);
> > }
> > print "\n";
> >
> > Note that if you replace line 6 with:
> >  print "Line $n\n";
> > on my system (Mac OS 10.5.7, Perl 5.10.0), the newline character forces
> > a flush regardless of the autoflush setting on STDOUT. You need to run
> > the program as shown above with and without line 4 to see the
> > difference.
> >
> > Your program looks like a CGI program. Are you trying to run it from a
> > command-line or from a browser? That will certainly affect your
> > expected results.

> Yes it is run from a browser.
> 
> Since autoflush has  been set then each line should be printed immediately 
> followed by a wait of so many seconds.
> 
> At present, all the output is buffered and then printed at one go.
> 
> At the weekend we upgraded the server from Debian Etch to Debian Lenny, and 
> from Perl 5.8.8 to Perl 5.10.
> 
> Previously the autoflush was working.

You can run the program included above from a command line to test
whether your Perl installation performs autoflushing correctly.
Hopefully, it does.

It is more likely that your web server or browser has changed behavior.
Autoflushing Perl's STDOUT means that partial lines will get to the web
server promptly. It doesn't mean that the web server will send the
lines to the browser promptly, or that the browser will display those
lines promptly in a browser window. Unfortunately, I don't think Perl
is going to be able to help you with this problem without a major
re-implementation. See, for example, the article:

<http://www.stonehenge.com/merlyn/LinuxMag/col39.html>

-- 
Jim Gibson


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

Date: Thu, 4 Jun 2009 23:15:28 +0100
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: print buffer in Perl 5.10
Message-Id: <0ltlf6-ei2.ln1@osiris.mauzo.dyndns.org>


Quoth Jim Gibson <jimsgibson@gmail.com>:
> 
> Note that if you replace line 6 with:
>   print "Line $n\n";
> on my system (Mac OS 10.5.7, Perl 5.10.0), the newline character forces
> a flush regardless of the autoflush setting on STDOUT. You need to run
> the program as shown above with and without line 4 to see the
> difference.

This is usual on (at least) Unix systems when STDOUT is a terminal. See
setbuf(3). You can see the usual full-buffered output using

    perl script | cat

(a Not Completely Useless Use of Cat :) ).

Ben



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

Date: Fri, 5 Jun 2009 00:23:47 +0200
From: "Peter J. Holzer" <hjp-usenet2@hjp.at>
Subject: Re: print buffer in Perl 5.10
Message-Id: <slrnh2gibj.hk2.hjp-usenet2@hrunkner.hjp.at>

On 2009-06-04 09:44, John <john1949@yahoo.com> wrote:
>
> "Ben Morrow" <ben@morrow.me.uk> wrote in message 
> news:s6kif6-ir2.ln1@osiris.mauzo.dyndns.org...
>>
>> Quoth "John" <john1949@yahoo.com>:
>>>
>>> Moved from Etch to Lenny in Debian and from Perl 5.8.8 to 5.10.
>>>
>>> Normally I use:
>>> our $old_fh=select(STDOUT); $|=1; select($old_fh); # Make standard output
>>> socket hot
>>> but this appears no longer to work and output is now buffered.
[...]
> The proram is embarrassingly small but I cannot stop the print buffer.

[program snipped]

Your program works fine on Debian Lenny. To test, invoke it like this:

$ ./john | cat

It will wait after each "<br>".

	hp



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

Date: Thu, 04 Jun 2009 15:09:32 -0400
From: Charlton Wilbur <cwilbur@chromatico.net>
Subject: Re: Update
Message-Id: <86fxefzuhf.fsf@mithril.chromatico.net>

>>>>> "EDG" == E D G <edgrsprj@ix.netcom.com> writes:

    EDG> Let me say again, regardless of what limitations it might have,
    EDG> I personally like the Perl programming language better than any
    EDG> other I have worked with over the years.  And I am recommending
    EDG> that other researchers use it. Whatever documentation is needed
    EDG> for the people that I work with can be easily created and
    EDG> stored on a Web page.

This is irrelevant to your question.

    EDG> Those comments regarding documentation were just added
    EDG> information.  The question that needed an answer is how to get
    EDG> Perl to detect key presses.

This is also irrelevant to your question.

    EDG> The main Perl program that needs to do that has already been up
    EDG> and running for some time.  And since early March of 2009 it
    EDG> has been available for use by governments and researchers
    EDG> around the world as a freeware download.

Still more content that's irrelevant to your question.

    EDG> It opens a pipe to Gnuplot and tells the program to display
    EDG> certain types of charts.  The IsKeyPressed command is used to
    EDG> detect key presses when Gnuplot charts are being displayed.
    EDG> So, the answer to that one question is "Yes." The Perl program
    EDG> needs to be able to detect key presses when some other program
    EDG> is the one actively displaying data.  Another of these programs
    EDG> has Perl detect key presses when a Word for Windows program is
    EDG> the one being displayed.

Finally, useful information!

(Most people would have moved on to the next article long before this point.)

    EDG> Two problems were encountered with IsKeyPressed.

    EDG> First, as far as I can tell, it does not do a good job of
    EDG> removing the key press from the Windows keyboard buffer.  So if
    EDG> a readline command is later used to get a line from the buffer
    EDG> the last character is still there.

    EDG> The second problem is that it would read only a limited number
    EDG> of keys.  For example, it does not appear to be able to
    EDG> distinguish between upper and lower case key presses.

    EDG> The ReadKey commands are somewhat more versatile.  But when
    EDG> Gnuplot is the screen being displayed they don't detect key
    EDG> presses from what I can tell

You are misunderstanding the purpose of IsKeyPressed.  

Windows has the notion of a stream of events.  Each event belongs to a
particular process.  At some point, and I'm not a Windows programmer so
I don't know where precisely this happens, this is translated into a
character of input for programs that think in terms of stdin/stdout.

Now, Windows routes each event to the window that it pertains to.
Keyboard events go to the active window.  When you're running Gnuplot,
this is the Gnuplot window, not the Perl window.  This is the core of
your problem, and why I think you need someone who understands
event-driven GUI programming to get involved.

The workaround you've chosen bypasses the event loop and deals directly
with events.  This means that you get told when a key is pressed -- but
you have to deal with it on the level of translating Shift plus A into
capital-A yourself.  This is almost certainly not what you really want
to do, and if you had that aforementioned event-driven GUI programmer on
staff, that's what he or she would tell you too.

Charlton



-- 
Charlton Wilbur
cwilbur@chromatico.net


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

Date: Thu, 04 Jun 2009 16:20:59 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: What happened to perl doc
Message-Id: <Xns9C207DAB5ED62asu1cornelledu@127.0.0.1>

perl man <klausfpga@gmail.com> wrote in
news:80ddda9c-27b3-4346-b59c-5630341b15ad@f10g2000vbf.googlegroups.com: 

> I use perldoc.perl.org a lot to browse perl documentation
> interactively
> Loosing this capability would be a real pity :-(

Why??? The documentation for your version of Perl is on your computer. 
Yes, even the HTML version (assuming ActiveState on Windows ).

I have no idea what's going on with perldoc.perl.org but 
http://perl.jonallen.info/projects/perldoc explains what to do when you 
have found a problem.

Sinan


-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

Date: Thu, 4 Jun 2009 09:38:00 -0700 (PDT)
From: perl man <klausfpga@gmail.com>
Subject: Re: What happened to perl doc
Message-Id: <1911f8ae-5522-473f-812d-adeba79b701c@s21g2000vbb.googlegroups.com>

On Jun 4, 2:43=A0pm, perl man <klausf...@gmail.com> wrote:
> Is this a bug or a new feature?
>
> What I notice:
>
> Working example: (perldoc for old perl versions)
> 1.) I go tohttp://perldoc.perl.org
> 2.) I select perl version 5.8.9
> 3.) I enter the word 'index' in the search field an and press enter.
> 4.) I see the help text about index.
>
> Now the failing example (perldoc for perl 5.10.0 )
> 1.) I go tohttp://perldoc.perl.org
> 2.) I select perl version 5.10.0 (or I just select no version at all)
> 3.) I enter the word 'index' in the search field an and press enter.
> 4.) I see no help text about index. I seem to have no hit.
> Friendly as perldoc is it suggests now:
>
> > Search results
>
> > The perldoc.perl.org search engine is optimised to index Perl functions=
, core modules, and FAQs. To perform a > full-text search of the documentat=
ion, please repeat your query using Google:
>
> > radio -box allowing to select the google search space
> > Google search button
>
> I hope this is just a current drop out.
>
> I use perldoc.perl.org a lot to browse perl documentation
> interactively
> Loosing this capability would be a real pity :-(

Thanks Sinan,

I use perldoc.perl.doc mostly when being on a windows host and writing
perl scripts for a remote linux machine via an xterm.

Of course I can scp the html tree to my local machine, but I like the
online documentation, which is available from any host whether perl is
installed or not


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

Date: Thu, 04 Jun 2009 19:32:45 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: What happened to perl doc
Message-Id: <Xns9C209E2E072B6asu1cornelledu@127.0.0.1>

perl man <klausfpga@gmail.com> wrote in
news:1911f8ae-5522-473f-812d-adeba79b701c@s21g2000vbb.googlegroups.com: 

> On Jun 4, 2:43 pm, perl man <klausf...@gmail.com> wrote:

<snip full copy of original question by klausfpga>

> Thanks Sinan,

You should learn how to reply to posts. You replied to your own post, 
and none of my comments were included in your reply which makes this 
"Thanks Sinan" look a little bit out of place.

> I use perldoc.perl.doc mostly when being on a windows host and writing
> perl scripts for a remote linux machine via an xterm.

Why??? Does the remote machine not have perldoc installed? Have you not 
heard of screen? Besides, why develop in such a painful way? Are you 
actually editing scripts on a live server?

> Of course I can scp the html tree to my local machine, but I like the
> online documentation, which is available from any host whether perl is
> installed or not

You should contact the site maintainers then.

However, you should also set yourself up with a development environment. 
This could be a cheapo laptop or a USB key. You would be able to write, 
debug, package, deploy scripts with ease.

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)

comp.lang.perl.misc guidelines on the WWW:
http://www.rehabitation.com/clpmisc/


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

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.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

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 V11 Issue 2459
***************************************


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