[22448] in Perl-Users-Digest
Perl-Users Digest, Issue: 4669 Volume: 10
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Mar 5 21:10:42 2003
Date: Wed, 5 Mar 2003 18:10:16 -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 Wed, 5 Mar 2003 Volume: 10 Number: 4669
Today's topics:
I want to know the line n umber of the error ! <ericosman-nospam@rcn.com>
Re: I want to know the line n umber of the error ! <asby@kinderen4kinderen.org>
Re: I want to know the line n umber of the error ! <ericosman-nospam@rcn.com>
Re: I want to know the line n umber of the error ! <eric.schwartz@hp.com>
Re: I want to know the line n umber of the error ! <tore@aursand.no>
Re: I want to know the line n umber of the error ! <ericosman-nospam@rcn.com>
Re: I want to know the line n umber of the error ! <bobx@linuxmail.org>
Re: I want to know the line n umber of the error ! <abigail@abigail.nl>
Re: I want to know the line n umber of the error ! <noreply@gunnar.cc>
Re: memory testing with Perl <tzz@lifelogs.com>
Re: memory testing with Perl <abigail@abigail.nl>
Re: Moving on a grd. <mail@annuna.com>
Re: Moving on a grd. <mail@annuna.com>
Re: parallelization of correlated nested loop ctcgag@hotmail.com
Re: parallelization of correlated nested loop <goldbb2@earthlink.net>
Re: Perl Script to Produce XML <asu1@c-o-r-n-e-l-l.edu>
Re: using system to run a program and redirect its outp <abigail@abigail.nl>
Re: XML to HTML <tore@aursand.no>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Wed, 05 Mar 2003 15:51:38 -0500
From: Eric Osman <ericosman-nospam@rcn.com>
Subject: I want to know the line n umber of the error !
Message-Id: <3E66635A.8060105@rcn.com>
How can I convince the server to tell me what line number it detects
my PERL error on ? I only get the following general error :
Software error:
Execution of /htdocs/e/r/ericosman/cgi-bin/reFormat.pl
aborted due to compilation errors.
For help, please send mail to the webmaster
(webmaster@rcn.com), giving this error message and the
time and date of the error.
I'd like it to tell me WHICH line number the error is detected on.
Is there a switch or directive I should be using beyond what I'm already
using ?
Here's my program so far:
#!/usr/bin/perl -w
%postInputs = readPostInput();
use CGI::Carp qw(fatalsToBrowser);
use Regexp::Common qw /URI/;
print "Content-type: text/html\n\n";
$dcWhole = $postInputs{'digestContents'};
@dcLines = split (/\r\n/ , $dcWhole);
foreach $dcLine (@dcLines) {
$dcLine =~ s#<#<#g;
$dcLine =~ s#>#>#g;
while($dcLine =~ s# # #g) {1};
$dcLine =~ s#$RE{URI}{HTTP}{-keep}#<a href="$1">$1</a>#g;
while ($dcLine$dcLine =~ s#mailto:[\w-@?=]#<a
href="$1">$1</a#g) {1};
print "<div>$dcLine</div>\n";
}
print "Done scanning\n";
sub readPostInput() {
my (%searchField, $buffer, $pair, @pairs);
if ($ENV{'REQUEST_METHOD'} eq 'POST') {
read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
@pairs = split(/&/,$buffer);
foreach $pair (@pairs) {
($name, $value) = split(/=/, $pair);
$value =~ tr/+/ /;
$value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$name =~ tr/+/ /;
$name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
$searchField{$name} = $value;
}
}
return (%searchField);
}
------------------------------
Date: Wed, 5 Mar 2003 22:14:05 +0100
From: "Asby" <asby@kinderen4kinderen.org>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <3e66689f$0$49113$e4fe514c@news.xs4all.nl>
"Eric Osman" <ericosman-nospam@rcn.com> wrote in message
news:3E66635A.8060105@rcn.com...
>
>
> How can I convince the server to tell me what line number it detects
> my PERL error on ? I only get the following general error :
You are using 'CGI::Carp qw(fatalsToBrowser);' so if your perl script is
running the 'fatals' will go to the browser, but since this didn't happened
the perl script never run. Does the .pl have the right rights and does the
system have a /usr/bin/perl ?
>
> For help, please send mail to the webmaster
> (webmaster@rcn.com), giving this error message and the
> time and date of the error.
And ofcourse you can send an email to the webmaster or if you are the
webmaster you can look in your apache logfile to see what went wrong.
--
ttfn,
Asby
$_="qdjb3H kqdP qdgsnmA srtJ";y/a-y3/b-za/;print scalar reverse
------------------------------
Date: Wed, 05 Mar 2003 17:13:05 -0500
From: Eric Osman <ericosman-nospam@rcn.com>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <3E667671.3070702@rcn.com>
That's not the problem. The perl script normally runs.
When I make some stupid typing error though, it stops running and I get
that general error.
What I really want of course is to be told what line number PERL thinks
the error is on.
Is there a way to make PERL show a line number ???
/Eric
------------------------------
Date: 05 Mar 2003 15:19:16 -0700
From: Eric Schwartz <eric.schwartz@hp.com>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <etozno9qwwr.fsf@wormtongue.emschwar>
Eric Osman <ericosman-nospam@rcn.com> writes:
> What I really want of course is to be told what line number PERL thinks
> the error is on.
>
> Is there a way to make PERL show a line number ???
perl (people here are somewhat testy about capitalization) *is*
telling you the line number-- it's putting it in the webserver's
error log. The webserver might be configurable to print that out as
well, but that problem is entirely independent of Perl (or perl). Ask
in a newsgroup about your webserver
(comp.infosystems.www.servers.{something}, most likely) for better
information.
-=Eric
--
Come to think of it, there are already a million monkeys on a million
typewriters, and Usenet is NOTHING like Shakespeare.
-- Blair Houghton.
------------------------------
Date: Wed, 05 Mar 2003 23:36:06 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <pan.2003.03.05.22.35.43.275131@aursand.no>
On Wed, 05 Mar 2003 15:51:38 -0500, Eric Osman wrote:
> How can I convince the server to tell me what line number it detects
> my PERL error on?
Why do you want to show the end user on what line your script fails? It
doesn't make sense.
As the developer - and maybe the web master - you should check the web
server's error log. There you will - most probably - find all the
information you'll ever need.
> #!/usr/bin/perl -w
#!/usr/bin/perl
#
use strict;
use warnings;
> %postInputs = readPostInput();
> sub readPostInput() {
> my (%searchField, $buffer, $pair, @pairs);
> if ($ENV{'REQUEST_METHOD'} eq 'POST') {
> read(STDIN, $buffer, $ENV{'CONTENT_LENGTH'});
> @pairs = split(/&/,$buffer);
> foreach $pair (@pairs) {
> ($name, $value) = split(/=/, $pair);
> $value =~ tr/+/ /;
> $value =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $name =~ tr/+/ /;
> $name =~ s/%([a-fA-F0-9][a-fA-F0-9])/pack("C", hex($1))/eg;
> $searchField{$name} = $value;
> }
> }
> return (%searchField);
> }
Ouch. Use CGI.pm instead!
> $dcWhole = $postInputs{'digestContents'};
> @dcLines = split (/\r\n/ , $dcWhole);
Why split? This code will do the same thing, AFAIK, and is using CGI.pm
instead. Not tested;
----
#!/usr/bin/perl
#
use strict;
use warnings;
## Requirements
use CGI qw(:cgi);
use CGI::Carp qw( fatalsToBrowser );
use Regexp::Common qw( URI );
## Assign variables
my $cgi = CGI->new();
my $dc = $cgi->param( 'digestContents' ) || '';
my $output = '';
## Convert (...)
my %conversions = (
'<' => '<',
'>' => '>',
' ' => ' ',
);
foreach ( keys %conversions ) {
$dc =~ s,$_,$conversions{$_},sig;
}
## Scan:
## Insert your code for fetching the links here. Append the output
## to the '$output' variable.
## Output
print $cgi->header(-type => 'text/html',
-length => length($output));
print $output;
----
--
Tore Aursand <tore@aursand.no>
------------------------------
Date: Wed, 05 Mar 2003 18:09:19 -0500
From: Eric Osman <ericosman-nospam@rcn.com>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <3E66839F.2000708@rcn.com>
I cannot change the server. I'm an RCN customer. It's their server.
So I want to know if there's something I can put in my perl script
so that the line number will show up during debugging.
Thanks. /Eric
------------------------------
Date: Wed, 05 Mar 2003 23:35:31 GMT
From: "Bob X" <bobx@linuxmail.org>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <7Rv9a.23953$0L3.10168067@news2.news.adelphia.net>
"Eric Schwartz" <eric.schwartz@hp.com> wrote in message
news:etozno9qwwr.fsf@wormtongue.emschwar...
> Eric Osman <ericosman-nospam@rcn.com> writes:
<snip>
> perl (people here are somewhat testy about capitalization)
lol, I was about to send something about it!
------------------------------
Date: 06 Mar 2003 00:40:57 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <slrnb6d68p.55o.abigail@alexandra.abigail.nl>
Eric Osman (ericosman-nospam@rcn.com) wrote on MMMCDLXXIII September
MCMXCIII in <URL:news:3E66839F.2000708@rcn.com>:
??
?? I cannot change the server. I'm an RCN customer. It's their server.
So? That's not our problem, is it?
?? So I want to know if there's something I can put in my perl script
?? so that the line number will show up during debugging.
HOW BONEHEADED CAN YOU BE?
You've been told more than one that Perl *IS* telling the number of
the line the error occurs on. The fact that the webserver doesn't
pass that information to the user is NOT, I repeat, NOT, a Perl issue.
You're paying your provider. If they don't want to give you access
to the logs, either take your business elsewhere, or get a different
contract.
Or you might want to try one of the suggestions already posted in
this thread.
Abigail
--
sub A::TIESCALAR{bless\my$x=>A};package B;@q[0..3]=qw/Hacker Perl
Another Just/;use overload'""'=>sub{pop @q};sub A::FETCH{bless\my
$y=>B}; tie my $shoe => qq 'A';print "$shoe $shoe $shoe $shoe\n";
------------------------------
Date: Thu, 06 Mar 2003 01:54:05 +0100
From: Gunnar Hjalmarsson <noreply@gunnar.cc>
Subject: Re: I want to know the line n umber of the error !
Message-Id: <b46669$1sae3m$1@ID-184292.news.dfncis.de>
Eric Osman wrote:
> So I want to know if there's something I can put in my perl script
> so that the line number will show up during debugging.
I think there is. Try importing the carpout routine from CGI::Carp.
http://www.perldoc.com/perl5.8.0/lib/CGI/Carp.html#REDIRECTING-ERROR-MESSAGES
/ Gunnar
--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl
------------------------------
Date: Wed, 05 Mar 2003 15:25:10 -0500
From: Ted Zlatanov <tzz@lifelogs.com>
Subject: Re: memory testing with Perl
Message-Id: <4nptp5h87t.fsf@lockgroove.bwh.harvard.edu>
On Wed, 05 Mar 2003, goldbb2@earthlink.net wrote:
> Ted Zlatanov wrote:
>> push @array, "0123456789ABCDEF";
> That's a total of 56 bytes, for a string that's 16 letters long.
Given this much overhead, maybe the chunks I'm reserving should be
1023-character strings (that should make the overhead less
significant).
More importantly, I know this is the wrong approach, I would much
rather ask Perl itself how much memory it has allocated.
Devel::MemUsage? :)
Thanks
Ted
------------------------------
Date: 06 Mar 2003 00:43:16 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: memory testing with Perl
Message-Id: <slrnb6d6d4.55o.abigail@alexandra.abigail.nl>
Ted Zlatanov (tzz@lifelogs.com) wrote on MMMCDLXXIII September MCMXCIII
in <URL:news:4nptp5h87t.fsf@lockgroove.bwh.harvard.edu>:
;; On Wed, 05 Mar 2003, goldbb2@earthlink.net wrote:
;; > Ted Zlatanov wrote:
;;
;; >> push @array, "0123456789ABCDEF";
;;
;; > That's a total of 56 bytes, for a string that's 16 letters long.
;;
;; Given this much overhead, maybe the chunks I'm reserving should be
;; 1023-character strings (that should make the overhead less
;; significant).
;;
;; More importantly, I know this is the wrong approach, I would much
;; rather ask Perl itself how much memory it has allocated.
;; Devel::MemUsage? :)
That doesn't exist on CPAN. But Devel::Size does.
Abigail
--
perl -MTime::JulianDay -lwe'@r=reverse(M=>(0)x99=>CM=>(0)x399=>D=>(0)x99=>CD=>(
0)x299=>C=>(0)x9=>XC=>(0)x39=>L=>(0)x9=>XL=>(0)x29=>X=>IX=>0=>0=>0=>V=>IV=>0=>0
=>I=>$==-2449231+gm_julian_day+time);do{until($=<$#r){$_.=$r[$#r];$=-=$#r}for(;
!$r[--$#r];){}}while$=;$,="\x20";print+$_=>September=>MCMXCIII=>=>=>=>=>=>=>=>'
------------------------------
Date: Wed, 05 Mar 2003 15:56:26 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Re: Moving on a grd.
Message-Id: <3E66728A.5070805@annuna.com>
Thanks so much for your help.
ctcgag@hotmail.com wrote:
> Joe Creaney <mail@annuna.com> wrote:
>
>
> You appear to be posting in some MIME or html format (although my
> reader protects me from it until I try reply. Please don't
> do that.
>
>
>>I did some work on my idea. My problem is that I want to use a foreach
>>loop to print out the values of the array @grid. I immagine that I
>>could get the program to work if I use nested for i = 1 to 5 to print
>>out the arrays.
>>
>>I have been playing with the program and it is realy buggs. I am still
>>working on it.
>>
>>Here is the code:
>
>
> You really, really, should 'use strict;' It would point many of your
> errors.
>
> <snip>
>
>
>>while ($l < 5) {
>
>
> foreach my $l (0..4) {
>
>
>> while ($l1 < 5 ) {
>
>
> foreach my $l1 (0..4) {
>
>
>> if (($l == $xp) and ($l1 == $yp)) {
>> print "*"; } else {
>> print "$grd[$l],[$l1]"; }
>> $l1++;
>> }
>
>
> Your formatting is weird. The else is more than cuddled, it's coddled!
> No commas are used between the brackets to access arrays. It's
> either $grd[$l][$l1] or $grd[$l]->[$l1]. (But in this case, you could
> just hard code in the ".", since it will never change. Unless of course
> you plan to add obstacles to grd in the future)
>
>
I am self taught and I often forget or overlook some detailes.
>
>> print "\n";
>> $l++;
>
>
> $l1=0;
>
> You need to reset $l1 also. (if you used the foreach, you wouldn't need to
> worry about that.)
Is that the case when the program re=accesses the subroutine, the
variables keep ther values one the function is exited. Can I use a
foreach loop with both dimentions of an array?
>
> <snip>
>
>>sub move {
>> my ($mi, $xm, $ym) = @_;
>> my %mov = (n => [ 0, -1], s => [ 0, 1], e => [1, 0], w => [-1,
>> 0]); $xm += $mov{$mi[0]};
>
> $xm += $mov{$mi}[0];
>
> This is the kind of thing strict tells you about.
>
> There are more problems (is it $xm or is it $mx?), but I'm
> bored now. use strict.
>
You have been much help. I often get distracted when writing programs
and loose my train of thought.
------------------------------
Date: Wed, 05 Mar 2003 19:39:04 -0600
From: Joe Creaney <mail@annuna.com>
Subject: Re: Moving on a grd.
Message-Id: <3E66A6B8.6010705@annuna.com>
This is a multi-part message in MIME format.
--------------010605070109050902020302
Content-Type: text/plain; charset=us-ascii; format=flowed
Content-Transfer-Encoding: 7bit
Working the bugs out it pretty much works except for the grid printing
function. Here is my code can I use nested foreach loops to print out
the data in my grid?
ctcgag@hotmail.com wrote:
> Joe Creaney <mail@annuna.com> wrote:
>
>
> You appear to be posting in some MIME or html format (although my
> reader protects me from it until I try reply. Please don't
> do that.
>
>
>>I did some work on my idea. My problem is that I want to use a foreach
>>loop to print out the values of the array @grid. I immagine that I
>>could get the program to work if I use nested for i = 1 to 5 to print
>>out the arrays.
>>
>>I have been playing with the program and it is realy buggs. I am still
>>working on it.
>>
>>Here is the code:
>
>
> You really, really, should 'use strict;' It would point many of your
> errors.
>
> <snip>
>
>
>>while ($l < 5) {
>
>
> foreach my $l (0..4) {
>
>
>> while ($l1 < 5 ) {
>
>
> foreach my $l1 (0..4) {
>
>
>> if (($l == $xp) and ($l1 == $yp)) {
>> print "*"; } else {
>> print "$grd[$l],[$l1]"; }
>> $l1++;
>> }
>
>
> Your formatting is weird. The else is more than cuddled, it's coddled!
> No commas are used between the brackets to access arrays. It's
> either $grd[$l][$l1] or $grd[$l]->[$l1]. (But in this case, you could
> just hard code in the ".", since it will never change. Unless of course
> you plan to add obstacles to grd in the future)
>
>
>
>> print "\n";
>> $l++;
>
>
> $l1=0;
>
> You need to reset $l1 also. (if you used the foreach, you wouldn't need to
> worry about that.)
>
> <snip>
>
>>sub move {
>> my ($mi, $xm, $ym) = @_;
>> my %mov = (n => [ 0, -1], s => [ 0, 1], e => [1, 0], w => [-1,
>> 0]); $xm += $mov{$mi[0]};
>
> $xm += $mov{$mi}[0];
>
> This is the kind of thing strict tells you about.
>
> There are more problems (is it $xm or is it $mx?), but I'm
> bored now. use strict.
>
> Xho
>
--------------010605070109050902020302
Content-Type: text/plain;
name="grd.pl"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
filename="grd.pl"
#! usr/bin/perl -w
use strict;
my $c;
my $i;
my $ypos= "0";
my $xpos= "0";
sub pgrid {
my ($xp,$yp) = @_;
my $l;
my $l1;
my @grd=(
[ qw( o o o o o )],
[ qw( o o o o o )],
[ qw( o o o o o )],
[ qw( o o o o o )],
[ qw( o o o o o )],
);
print "Printing Grid \n";
foreach $l (@grd) {
for ( $l1=0; $l1 >4; $l1++) {
if (($l == $xp) and ($l1 == $yp)) {
print "*"; } else {
print "$grd[$l] [$l1]"; }
print "$l $l1";
}
print "\n";
print "$grd[$l][$l1]";
}
}
sub move {
my ($mi, $xm, $ym) = @_;
my %mov = ( n => [ 0, -1], s => [ 0, 1], e => [1, 0], w => [-1, 0], q => [0, 0]);
$xm = $xm + $mov{$mi}[0];
$ym = $ym + $mov{$mi}[1];
if ($xm > 5)
{$xm=0;}
if ($xm < 0)
{$xm=4;}
if ($ym > 5)
{$ym=0;}
if ($ym < 0)
{$ym=4;}
return $mi, $xm, $ym;
}
pgrid ($xpos,$ypos);
while ($i ne "q") {
print "Which way:";
$i=<STDIN>; chomp $i;
($i, $xpos, $ypos) = move($i, $xpos, $ypos);
pgrid ($xpos, $ypos);
print "$xpos $ypos $i \n";
exit if ($i=~/^q/)
}
print "You are done!";
--------------010605070109050902020302--
------------------------------
Date: 05 Mar 2003 21:41:23 GMT
From: ctcgag@hotmail.com
Subject: Re: parallelization of correlated nested loop
Message-Id: <20030305164123.273$Wh@newsreader.com>
Martien Verbruggen <mgjv@tradingpost.com.au> wrote:
> On 05 Mar 2003 01:59:06 GMT,
> ctcgag@hotmail.com <ctcgag@hotmail.com> wrote:
> > I need to take an input of ~2e6 items, and find an output list
> > (I think it will be ~1e5 items) where each item already in the output
> > list can veto any new addition. It's easier explained in perl:
> >
> >
> > my @in=<IN>;
> > shuffle(\@in);
> >
> > my @good;
> >
> > OUTER: foreach my $prospect ( @in ) {
> > foreach my $good (@good) {
> > next OUTER if veto($good,$prospect) ;
> > };
> > push @good, $_
> > };
> > print join "\n", @good;
> >
> > __END__
>
> If you'd posted veto() and shuffle(), maybe people could suggest an
> algorithm change to speed it up.
shuffle() is just the Fisher-Yates from perldoc. Its performance is (alas)
inconsequential to the overall performance. I included it only
to tip people off that I have no need to take pains to collate the
responses from slaves into the "original" order, as I am intentionally
breaking the original order.
veto() is long, abstruse, and not much to do with perl, and inflicting
it on this group would be a distraction from what I really want help
with. Also, there may be lawyerly issues attached to veto() internals,
while the general problem I presented is certainly free of those.
> Without those, it is going to be
> impossible to say whether that double loop (over @in and @good) is
> necessary, or whether it could be replaced with something else.
Trust me, it's necessary. I've looked into it a lot. And it's not the
type of thing I'd ask y'all to do for me for free anyway. The more general
problem, however, seems more perlish and more like something others may
have covered in their own works.
> It is
> also impossible to say whether the process could be changed to read
> line by line, instead of the whole file at once
It's possible to read one line at a time (I originally had it that way, but
changed it to a slurp so the shuffle could be done inline), but memory
size is not an issue in this case, it fits comfortably in the few
hundred meg (per processor) that's available.
> Maybe, instead of @good, it would be better to keep a C-accessible
> hash. hard to tell. But it surely smells like that to me.
I've turned @in into one giant string of packed fixed length records
to pass into a C XSub, having the XSub implement both the inner and
outer loop directly in C, but that wasn't fast enough to disuade me from
persuing a parallel approach. Same with an XSub that implements the loops
using an "R-tree"-like data structure which obviates the need for 2/3 of
the (inlined) veto calls. (In fact, I intend to combine this XSub with the
parallel approach, once I have a working parallel prototype in pure perl.)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service New Rate! $9.95/Month 50GB
------------------------------
Date: Wed, 05 Mar 2003 17:56:12 -0500
From: Benjamin Goldberg <goldbb2@earthlink.net>
Subject: Re: parallelization of correlated nested loop
Message-Id: <3E66808C.57C22A1A@earthlink.net>
ctcgag@hotmail.com wrote:
>
> I need to take an input of ~2e6 items, and find an output list
> (I think it will be ~1e5 items) where each item already in the output
> list can veto any new addition. It's easier explained in perl:
>
> my @in=<IN>;
> shuffle(\@in);
>
> my @good;
>
> OUTER: foreach my $prospect ( @in ) {
> foreach my $good (@good) {
> next OUTER if veto($good,$prospect) ;
> };
> push @good, $_
> };
> print join "\n", @good;
>
> __END__
>
> I want to make it faster.
[snip]
> Anyone see a better way to parallelize this in Perl with simple
> forking methods? (I don't want to get into the business of doing
> parallel programming in C, or shared memory in Perl, unless absolutely
> necessary).
use Fcntl qw(:flock);
my @IN = <IN>;
open OUT, ">>+", "resultsfile";
binmode OUT;
$| = 1, select $_ for select OUT;
pipe my ($from_parent, $to_child);
for my $i ( 1 .. $num_processors ) {
fork and next;
close $to_child;
GET_DATA: while( 1 ) {
flock $from_parent, LOCK_EX;
my $buf = "";
sysread( $from_parent, $buf, 4 - length $buf, length $buf )
or exit while length($buf) < 4;
flock $from_parent, LOCK_UN;
my $prospect = $in[ unpack 'N', $buf ];
for my $good (@good) {
next GET_DATA if veto($good, $prospect);
}
$buf = my_pack($prospect);
flock OUT, LOCK_EX;
print OUT $buf;
flock OUT, LOCK_UN;
} # end of GET_DATA loop.
}
print $to_child pack 'N', $_ for 0 .. $#IN;
wait for 1 .. $num_processors;
seek OUT, 0, 0;
# read results from OUT.
__END__
Using sysread() (NOT read(), NOT <>, NOT readline()), in a loop like
that *is* necessary.
The locking on OUT for writing MIGHT not be necessary (due to append
mode) *if* your the serialized $prospect is a small enough string. I
wouldn't count on it though.
Creating more processes than you have CPUs won't give you much, if any,
advantage.
--
$;=qq qJ,krleahciPhueerarsintoitq;sub __{0 &&
my$__;s ee substr$;,$,&&++$__%$,--,1,qq;;;ee;
$__>2&&&__}$,=22+$;=~y yiy y;__ while$;;print
------------------------------
Date: 5 Mar 2003 19:47:07 GMT
From: "A. Sinan Unur" <asu1@c-o-r-n-e-l-l.edu>
Subject: Re: Perl Script to Produce XML
Message-Id: <Xns9335965E12B07asu1cornelledu@132.236.56.8>
"Michael Hill" <hillmw@charter.net> wrote in
news:v6aruoclc73pea@corp.supernews.com:
> I fixed the header and still was getting another problem. Based on
> what I saw on that Apache site I added to my .htaccess
> file "AddHandler cgi-script .cgi" in my html directory.
>
> So.... the same script xml.cgi runs in the /html directory, but not
> in the /cgi-bin directory. Here are the links:
>
> http://www.hulenbend.net/xml.cgi
> http://www.hulenbend.net/cgi-bin/xml.cgi
>
> Here is the cgi:
>
> print "Content-type: text/xml; charset=utf-8\n\n";
> print "<?xml:stylesheet type='text/xsl' href='ops_rev.xsl'?>\n";
is there a file called ops_rev.xsl in your cgi-bin? i am guessing not.
what happens when you replace the line above with
print "<?xml:stylesheet type='text/xsl' href='/ops_rev.xsl'?>\n";
--
A. Sinan Unur
asu1@c-o-r-n-e-l-l.edu
Remove dashes for address
Spam bait: mailto:uce@ftc.gov
------------------------------
Date: 05 Mar 2003 23:20:44 GMT
From: Abigail <abigail@abigail.nl>
Subject: Re: using system to run a program and redirect its output
Message-Id: <slrnb6d1ic.55o.abigail@alexandra.abigail.nl>
wendy (shukwong@yahoo.com) wrote on MMMCDLXXIII September MCMXCIII in
<URL:news:b44h9r$p6g$1@news01.cit.cornell.edu>:
}} Hi, I was trying to run a program in perl with system() and then redirect
}} its output
}} something like
}} system("./myprog >testout1");
}}
}} However, the output still showed up on the screen and testout1 was created
}} but empty. Anyone know why?
Some possibilities: myprog writes to STDERR, or to /dev/tty.
But without knowing myprog, who could tell?
Abigail
--
sub _ {$_ = shift and y/b-yB-Y/a-yB-Y/ xor !@ _?
exit print :
print and push @_ => shift and goto &{(caller (0)) [3]}}
split // => "KsvQtbuf fbsodpmu\ni flsI " xor & _
------------------------------
Date: Wed, 05 Mar 2003 23:36:06 +0100
From: "Tore Aursand" <tore@aursand.no>
Subject: Re: XML to HTML
Message-Id: <pan.2003.03.05.22.20.23.833654@aursand.no>
On Tue, 04 Mar 2003 15:56:04 +0000, Peter Cooper wrote:
>> Why don't you just (...) write a stylesheet for the XML file?
> Varying browser support and various browser inconsistencies might be the
> problem with that method.
He didn't say anything about that, just that "he wanted the data to be
viewed in a browser". If he really wants the data to be viewed in any
(...) browser, then he should have said so.
--
Tore Aursand <tore@aursand.no>
------------------------------
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 4669
***************************************