[29783] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 1026 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Mon Nov 12 14:09:43 2007

Date: Mon, 12 Nov 2007 11:09: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           Mon, 12 Nov 2007     Volume: 11 Number: 1026

Today's topics:
    Re: File Size Limit in Archive::Perl (replace z with h, spam protection)
    Re: Form type input for the console <justin.0711@purestblue.com>
        How can I change the Content-Type of Perl-CGI scripts? <tarmstrong@gmail.com>
    Re: How can I change the Content-Type of Perl-CGI scrip <jurgenex@hotmail.com>
    Re: How can I change the Content-Type of Perl-CGI scrip <rkb@i.frys.com>
        Index of first and last non-"\xff" in a long string  w.c.humann@arcor.de
        oddness in quotes (PerlMagick) <myicq2@3gmx.net4>
    Re: oddness in quotes (PerlMagick) <peter@makholm.net>
    Re: oddness in quotes (PerlMagick) <stoupa@practisoft.cz>
    Re: oddness in quotes (PerlMagick) <uri@stemsystems.com>
    Re: oddness in quotes (PerlMagick) <myicqKATTE@bakkegmx.net>
    Re: oddness in quotes (PerlMagick) <1usa@llenroc.ude.invalid>
        Reg- Floating point variables <nithyananthamm@yahoo.com>
    Re: Reg- Floating point variables <smallpond@juno.com>
    Re: Reg- Floating point variables <jurgenex@hotmail.com>
    Re: Reg- Floating point variables <1usa@llenroc.ude.invalid>
    Re: Reg- Floating point variables <spamtrap@dot-app.org>
        Remove slow debug prints with "ifdef" type of pre proce  kebabklubben.emp@gmail.com
    Re: Remove slow debug prints with "ifdef" type of pre p <ben@morrow.me.uk>
    Re: Remove slow debug prints with "ifdef" type of pre p <bugbear@trim_papermule.co.uk_trim>
    Re: sleep/fork/shell/SIGCHLD interaction problem <ben@morrow.me.uk>
    Re: sleep/fork/shell/SIGCHLD interaction problem xhoster@gmail.com
        syntax question in dealing with .Net api  trillich@gmail.com
        WhenProblem calling perldb from a script, the current s <t.mittelstaedt@cadenas.de>
    Re: zipping large file using Archive::Zip <paul.marquess@btinternet.com>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Mon, 12 Nov 2007 14:32:23 +0100
From: "D. Marxsen" <detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)>
Subject: Re: File Size Limit in Archive::Perl
Message-Id: <fh9kpm$hr8$1@murphy.mediascape.de>

"San" <anoopsanthosh@gmail.com> wrote 
news:1194694480.993935.212260@z24g2000prh.googlegroups.com...

> Is there any way to limit the file size while zipping using
> Archive::Zip so that it will stop processing a zip operation on a file
> list when it crosses the maximum file size.

Well, I never used Archive::Zip - anyhow here my ideas, should Archive::Zip 
have no suitable control:

1.
Collect all files to be zipped with a recursive directory search.
2.
Create the archive file by file and after each extension get its size using 
the stat command.

Pretty sure not fast, but a working solution anyhow.


Regards,
Detlef.


-- 
D. Marxsen, TD&DS GmbH
detlef.marxsen@tdds-gmbz.de (replace z with h, spam protection)



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

Date: Mon, 12 Nov 2007 15:30:21 -0000
From: Justin C <justin.0711@purestblue.com>
Subject: Re: Form type input for the console
Message-Id: <1ac9.4738718d.680d8@zem>

On 2007-11-09, J. Gleixner <glex_no-spam@qwest-spam-no.invalid> wrote:
> Justin C wrote:
>> I'm looking to collect some repetitive data from the command line. It'd
>> be nice to have an on-screen form for the users. I've never used perl
>> for this kind of thing before, 
>
> What have you used for this kind of thing before?  Maybe that'll
> help someone figure out what you're asking for.

Web-browser based form.


> > can anyone point me at some relevant
>> documentation for generating an on-screen form? Learning Perl
>> doesn't get that far.
>
> Possibly Curses?

That seems most likely, thank you, and thanks also to Michele and
Sherman for mentioning it too.


> Or reading/storing the replies to prompts and using those replies
> when needed.

I'm not certain what you mean, but that may be down to you not
understanding what I mean.


> Or providing an example of the repetitive data and how it's
> to be used, maybe an 'on-screen form' isn't the best thing
> to do.

It's: contact name, business name, address, town, zip, country, tel,
fax, email.

I'm after a quick and dirty way of collecting these into a plain text
file for later import to a database. My reason for wanting to use a
terminal, rather than a web-browser, is speed. My typists are efficient,
I don't want them delayed by slow web-browsers.

Thanks for the suggestions, if the above stimulates further ideas I'd be
happy to hear them.

	Justin.

-- 
Justin C, by the sea.


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

Date: Mon, 12 Nov 2007 17:41:58 -0000
From:  Thomas Armstrong <tarmstrong@gmail.com>
Subject: How can I change the Content-Type of Perl-CGI scripts?
Message-Id: <1194889318.718138.41280@57g2000hsv.googlegroups.com>


Hi.

Working with Apache 2.0 (on a customer's server and on my own server),
I've got a '500 Internal Server Error' with a CGI application. When
accessing 'http://customer_machine/test.cgi', Firefox tries to
download the error webpage.

But when accessing 'http://my_own_machine/test.cgi', Firefox shows the
HTML error webpage.

Analyzing headers

---------------------------------------
http://customer_machine/test.cgi
HTTP/1.1 500 Internal Server Error
Content-Type: application/x-cgi
----------------------------------------

--------------------------------------
http://my_own_machine/test.cgi
HTTP/1.1 500 Internal Server Error
Content-Type: text/html; charset=iso-8859-1
--------------------------------------

How can I change the Content-Type of CGI scripts?

Thank you very much.



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

Date: Mon, 12 Nov 2007 18:06:56 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: How can I change the Content-Type of Perl-CGI scripts?
Message-Id: <4D0_i.11011$h61.2755@trndny02>

Thomas Armstrong wrote:
> How can I change the Content-Type of CGI scripts?

Just a very wild guess: maybe by changing the parameter(s) of the header() 
method?

jue 




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

Date: Mon, 12 Nov 2007 10:17:22 -0800
From:  Ron Bergin <rkb@i.frys.com>
Subject: Re: How can I change the Content-Type of Perl-CGI scripts?
Message-Id: <1194891442.680781.256760@v23g2000prn.googlegroups.com>

On Nov 12, 9:41 am, Thomas Armstrong <tarmstr...@gmail.com> wrote:
> Hi.
>
> Working with Apache 2.0 (on a customer's server and on my own server),
> I've got a '500 Internal Server Error' with a CGI application. When
> accessing 'http://customer_machine/test.cgi', Firefox tries to
> download the error webpage.
>
> But when accessing 'http://my_own_machine/test.cgi', Firefox shows the
> HTML error webpage.
>
> Analyzing headers
>
> ---------------------------------------http://customer_machine/test.cgi
> HTTP/1.1 500 Internal Server Error
> Content-Type: application/x-cgi
> ----------------------------------------
>
> --------------------------------------http://my_own_machine/test.cgi
> HTTP/1.1 500 Internal Server Error
> Content-Type: text/html; charset=iso-8859-1
> --------------------------------------
>
> How can I change the Content-Type of CGI scripts?

Well, that depends on whether you're referring to the headers your cgi
script outputs or the headers of the web server's error page that was
returned.



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

Date: Mon, 12 Nov 2007 10:22:56 -0800
From:  w.c.humann@arcor.de
Subject: Index of first and last non-"\xff" in a long string
Message-Id: <1194891776.206718.48640@o3g2000hsb.googlegroups.com>

I'm going through several PGM images, overlaying (i.e. ANDing) them
and would also like to determine the bounding box. For that I need to
find the first and last non-white (i.e. non-"\xff") pixel in every
line. Now I have one line in a string $data (one pixel per character),
possibly several 1000 charcters long. I tried 3 alternatives so far.
All 3 work, but there may be even faster ways to do this:

# slow
my $first = -1;
1 while substr($data, ++$first, 1) eq "\xff" and $first < $width - 1;
my $last = $width;
1 while substr($data, --$last, 1) eq "\xff" and $last > $first;
print STDERR "f: $first, l: $last, ";

# the match for $first2 is fast, but the one for $last2 is really slow
my $first2 = length( ($data =~ /^(\xff+)/)[0] );
my $last2 = $width - 1 - length( ($data =~ /(\xff+)$/)[0] );
print STDERR "f2: $first2, l2: $last2, ";

# best solution so far. "tr" is the slowest part of this.
# Is there a way without the "tr"?
$data =~ tr|\x00-\xfe|\x00|;
my $first3 = index  $data, "\x00";
my $last3  = ($first3 > -1) ? rindex $data, "\x00" : -1;
print STDERR "f3: $first3, l3: $last3, ";

print STDERR "\n";

Thanks,
Wolfram



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

Date: 12 Nov 2007 06:17:31 GMT
From: myicq <myicq2@3gmx.net4>
Subject: oddness in quotes (PerlMagick)
Message-Id: <Xns99E64A2A164C0myicqgmxnet@212.242.40.162>

I have done some experimenting with Perl Magick and
unicode.

I have found a very strange thing with quotes. Can someone explain the 
following:


# this will fail, resulting in output
# of literal string   \x{0416}
# using SINGLE quotes

$image->Annotate(
		font=>'arial.ttf',
		text=>'\x{0416}');


# this will work
# resulting in a single character
# using DOUBLE quotes

$image->Annotate(
		font=>'arial.ttf',
		text=>"\x{0416}"
    	    	);


My question is: I thought Perl did not differ between single and double 
quotes, as long as used consistently in a string.

Btw, using Windows version of Perl and GM.



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

Date: Mon, 12 Nov 2007 06:25:17 +0000
From: Peter Makholm <peter@makholm.net>
Subject: Re: oddness in quotes (PerlMagick)
Message-Id: <87sl3casky.fsf@hacking.dk>

myicq <myicq2@3gmx.net4> writes:

> I have found a very strange thing with quotes. Can someone explain the 
> following:

'perldoc perlop' can explain it. Read the part starting with 'Quote
and Quote-like Operators'.

> My question is: I thought Perl did not differ between single and double 
> quotes, as long as used consistently in a string.

No, double quotes interpolates while single quotes doesn't. Escape
sequences are only available in quote constructs that
interpolates. (most of them are also available in translitterations
but that is not relevant here)

//Makholm


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

Date: Mon, 12 Nov 2007 07:30:41 +0100
From: "Petr Vileta" <stoupa@practisoft.cz>
Subject: Re: oddness in quotes (PerlMagick)
Message-Id: <fh8sbk$2ov3$1@ns.felk.cvut.cz>

myicq wrote:
> I have done some experimenting with Perl Magick and
> unicode.
>
> I have found a very strange thing with quotes. Can someone explain the
> following:
>
>
> # this will fail, resulting in output
> # of literal string   \x{0416}
This IS string but you meant character, right?

> text=>'\x{0416}');
This is string AS IS

> text=>"\x{0416}"
This is unicode character

> My question is: I thought Perl did not differ between single and
> double quotes, as long as used consistently in a string.
You thought bad ;-) Perl diifer between single and double quoutes. Single 
quoutes say "this is string as you see it" but souble quoutes say "Evauluate 
all between quotes".
So run this example:

my $text = 'ABC';
print 'This is text: $text\n';
print "This is text: $text\n";

-- 

Petr Vileta, Czech republic
(My server rejects all messages from Yahoo and Hotmail. Send me your mail 
from another non-spammer site please.)




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

Date: Mon, 12 Nov 2007 06:53:09 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: oddness in quotes (PerlMagick)
Message-Id: <x78x54hs4q.fsf@mail.sysarch.com>

>>>>> "m" == myicq  <myicq2@3gmx.net4> writes:

  m> My question is: I thought Perl did not differ between single and
  m> double quotes, as long as used consistently in a string.

where did you learn that? have you ever used interpolation in a perl
string? it would make little sense to have both quote do the same thing.

and as someone else pointed out, it is easy to look up quotes in the
docs.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org


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

Date: 12 Nov 2007 10:02:13 GMT
From: T <myicqKATTE@bakkegmx.net>
Subject: Re: oddness in quotes (PerlMagick)
Message-Id: <Xns99E670455F866myicqKATTEbakkegmxne@62.243.74.163>

Peter Makholm <peter@makholm.net> wrote in news:87sl3casky.fsf@hacking.dk:

> myicq <myicq2@3gmx.net4> writes:
> 
>> I have found a very strange thing with quotes. Can someone explain the 
>> following:
> 
> 'perldoc perlop' can explain it. Read the part starting with 'Quote
> and Quote-like Operators'.

THANK YOU for the detailed answer. Guess I learned an important lesson
or two.. and first of all: RTFM before asking.

Thank you again, also to other people that replied.

My bad


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

Date: Mon, 12 Nov 2007 15:33:13 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: oddness in quotes (PerlMagick)
Message-Id: <Xns99E66B56854E2asu1cornelledu@127.0.0.1>

myicq <myicq2@3gmx.net4> wrote in news:Xns99E64A2A164C0myicqgmxnet@
212.242.40.162:

> I thought Perl did not differ between single and double 
> quotes, as long as used consistently in a string.

perldoc perlop

esp. "Quote and Quote-like Operators"

Sinan


-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Mon, 12 Nov 2007 06:13:47 -0800
From:  Nithy <nithyananthamm@yahoo.com>
Subject: Reg- Floating point variables
Message-Id: <1194876827.609769.271960@z24g2000prh.googlegroups.com>

Hi,
  Can anyone help me in floating point round off error. I have the
code as shown below.

#!/usr/bin/perl
#This program increments the value from x.1 to x.9

$count = 0;
$out = 0;
while($out == 0)
{
print ("count = ",$count,"\n");
$count=$count + 0.1;
if ($count == 0.9)
{
$out=1;
}

If I run this code, it doesn't terminate when $count reach 0.9. Its
keep on increasing. And after 5.9 its showing 5.99999999999999 & so
on..
But If I limits it within 0.8(if $count = 0.1 - 0.7), it gives the
proper output. Why is it so?

Please let me know your suggestion.

Thanks in advance.

Regards,
Nithy



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

Date: Mon, 12 Nov 2007 06:58:01 -0800
From:  smallpond <smallpond@juno.com>
Subject: Re: Reg- Floating point variables
Message-Id: <1194879481.697362.163850@o80g2000hse.googlegroups.com>

On Nov 12, 9:13 am, Nithy <nithyananth...@yahoo.com> wrote:
> Hi,
>   Can anyone help me in floating point round off error. I have the
> code as shown below.
>
> #!/usr/bin/perl
> #This program increments the value from x.1 to x.9
>
> $count = 0;
> $out = 0;
> while($out == 0)
> {
> print ("count = ",$count,"\n");
> $count=$count + 0.1;
> if ($count == 0.9)
> {
> $out=1;
>
> }
>
> If I run this code, it doesn't terminate when $count reach 0.9. Its
> keep on increasing. And after 5.9 its showing 5.99999999999999 & so
> on..
> But If I limits it within 0.8(if $count = 0.1 - 0.7), it gives the
> proper output. Why is it so?
>
> Please let me know your suggestion.
>
> Thanks in advance.
>
> Regards,
> Nithy



Never try to test for exactly equal to a floating point number.
It doesn't work.  Floating point numbers are approximate.
Change your code to
if ($count >= 0.9)
--S



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

Date: Mon, 12 Nov 2007 15:23:45 GMT
From: "Jürgen Exner" <jurgenex@hotmail.com>
Subject: Re: Reg- Floating point variables
Message-Id: <5e_Zi.1387$eV.499@trndny04>

Nithy wrote:
> If I run this code, it doesn't terminate when $count reach 0.9. Its
> keep on increasing. And after 5.9 its showing 5.99999999999999 & so
> on..
> But If I limits it within 0.8(if $count = 0.1 - 0.7), it gives the
> proper output. Why is it so?

You must have missed "Basics of Computer Numerics":
    Thou shalt not test for equal on floating point numbers

'perldoc -q 999' gives a very brief introduction of why using floating point 
numbers has it quirks in Perl, too, just like in any other standard 
programming language.

jue 




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

Date: Mon, 12 Nov 2007 15:30:55 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Reg- Floating point variables
Message-Id: <Xns99E66AF2F70FCasu1cornelledu@127.0.0.1>

Nithy <nithyananthamm@yahoo.com> wrote in news:1194876827.609769.271960
@z24g2000prh.googlegroups.com:

> #!/usr/bin/perl
> #This program increments the value from x.1 to x.9

for my $i ( 1 .. 9 ) {
   $x += $i/10;
}

> Why is it so?

perldoc -q 999

Sinan

-- 
A. Sinan Unur <1usa@llenroc.ude.invalid>
(remove .invalid and reverse each component for email address)
clpmisc guidelines: <URL:http://www.augustmail.com/~tadmc/clpmisc.shtml>



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

Date: Mon, 12 Nov 2007 11:39:49 -0500
From: Sherman Pendley <spamtrap@dot-app.org>
Subject: Re: Reg- Floating point variables
Message-Id: <m1ir47ct9m.fsf@dot-app.org>

Nithy <nithyananthamm@yahoo.com> writes:

> If I run this code, it doesn't terminate when $count reach 0.9. Its
> keep on increasing. And after 5.9 its showing 5.99999999999999 & so
> on..
> But If I limits it within 0.8(if $count = 0.1 - 0.7), it gives the
> proper output. Why is it so?

This is a FAQ. Have a look at:

    perldoc -q 999

> Please let me know your suggestion.

In a nutshell, some numbers cannot be exactly represented in binary, for
the same reason that numbers such as one-third cannot be exactly represented
in decimal.

For this reason, it's best to avoid direct equality tests on floating-point
numbers. For example, you could rewrite your test of $count to:

    if ($count >= 0.9) { ... }

Another common technique is to measure the difference (aka delta) between a
float and a known value, and consider them equal if the delta is small enough:

    if (abs(0.9 - $count) < 0.000001) { ... }

For more (much more) detail, have a look at "What every computer scientist
should know about floating-point arithmetic."

    <http://docs.sun.com/source/806-3568/ncg_goldberg.html>

sherm--

-- 
WV News, Blogging, and Discussion: http://wv-www.com
Cocoa programming in Perl: http://camelbones.sourceforge.net


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

Date: Mon, 12 Nov 2007 06:00:01 -0800
From:  kebabklubben.emp@gmail.com
Subject: Remove slow debug prints with "ifdef" type of pre processor pragma.
Message-Id: <1194876001.782762.215730@v3g2000hsg.googlegroups.com>

Hi!

Is there a way to remove slow debug prints with some kind of "ifdef"
type of pre processor pragma?

They are to slow when I ran big batch jobs, but neat to have durinf
development. Is there a way in Perl do define that debug prints are
skipped without any loop overhead?

Best Regards,
Andreas Lundgren - Sweden



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

Date: Mon, 12 Nov 2007 14:42:59 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
Message-Id: <jc5m05-631.ln1@osiris.mauzo.dyndns.org>


Quoth kebabklubben.emp@gmail.com:
> 
> Is there a way to remove slow debug prints with some kind of "ifdef"
> type of pre processor pragma?
> 
> They are to slow when I ran big batch jobs, but neat to have durinf
> development. Is there a way in Perl do define that debug prints are
> skipped without any loop overhead?

perldoc constant

Ben



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

Date: Mon, 12 Nov 2007 15:23:48 +0000
From: bugbear <bugbear@trim_papermule.co.uk_trim>
Subject: Re: Remove slow debug prints with "ifdef" type of pre processor pragma.
Message-Id: <13jgs04ofbk0p3b@corp.supernews.com>

kebabklubben.emp@gmail.com wrote:
> Hi!
> 
> Is there a way to remove slow debug prints with some kind of "ifdef"
> type of pre processor pragma?
> 
> They are to slow when I ran big batch jobs, but neat to have durinf
> development. Is there a way in Perl do define that debug prints are
> skipped without any loop overhead?

This or something like it?

http://log4perl.sourceforge.net/

   BugBear


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

Date: Mon, 12 Nov 2007 14:34:48 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: sleep/fork/shell/SIGCHLD interaction problem
Message-Id: <8t4m05-631.ln1@osiris.mauzo.dyndns.org>


Quoth xhoster@gmail.com:
> Justin Fletcher <gerph@gerph.org> wrote:
> >
> > I'm having a problem trying to get a simple program to respond the way
> > that I expect. The basic premise is thus :
> >
> > 1. Fork a child.
> > 2. Sleep for a while.
> > 3. Do other stuff.
> >
> > This seems pretty simple, and I have a SIGCHLD handler which will catch
> > my forked process if it exits. I thought everything was fine. Then I
> > found that is I press ctrl-Z to suspend the parent whilst I'm running the
> > program and then background it, it hangs.
> 
> I find that this only occurs if I hit ctrl-Z from the keyboard.  If I
> send the process the TSTP signal via some other means, it doesn't happen.
> I know that shells often respond to ctrl-Z, ctrl-C, etc, by sending signals
> to entire process groups, rather than just the main process.  I don't
> exactly how this leads to the observed phenomena, though.

SIGCHLD is sent to the parent whenever a child changes status. So when
you press ctrl-Z, the whole process group is signalled, the child is
stopped, and the parent gets a SIGCHLD. When the process group is
resumed (bg or fg) the parent gets another SIGCHLD: since it hasn't
responded to the first yet (because it was stopped), this is not
usually apparent.

If the OP really doesn't want SIGCHLDs when a child stops, he can
install the signal handler explicitly with sigaction and SA_NOCLDSTOP
(under systems which support that). Since one must assume that any
number of children may have exitted when handling SIGCHLD anyway,
including 0 in 'any number' is generally easier.

Ben



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

Date: 12 Nov 2007 17:46:44 GMT
From: xhoster@gmail.com
Subject: Re: sleep/fork/shell/SIGCHLD interaction problem
Message-Id: <20071112124646.451$Vo@newsreader.com>

Ben Morrow <ben@morrow.me.uk> wrote:
> Quoth xhoster@gmail.com:
> > Justin Fletcher <gerph@gerph.org> wrote:
> > >
> > > I'm having a problem trying to get a simple program to respond the
> > > way that I expect. The basic premise is thus :
> > >
> > > 1. Fork a child.
> > > 2. Sleep for a while.
> > > 3. Do other stuff.
> > >
> > > This seems pretty simple, and I have a SIGCHLD handler which will
> > > catch my forked process if it exits. I thought everything was fine.
> > > Then I found that is I press ctrl-Z to suspend the parent whilst I'm
> > > running the program and then background it, it hangs.
> >
> > I find that this only occurs if I hit ctrl-Z from the keyboard.  If I
> > send the process the TSTP signal via some other means, it doesn't
> > happen. I know that shells often respond to ctrl-Z, ctrl-C, etc, by
> > sending signals to entire process groups, rather than just the main
> > process.  I don't exactly how this leads to the observed phenomena,
> > though.
>
> SIGCHLD is sent to the parent whenever a child changes status. So when
> you press ctrl-Z, the whole process group is signalled, the child is
> stopped, and the parent gets a SIGCHLD. When the process group is
> resumed (bg or fg) the parent gets another SIGCHLD: since it hasn't
> responded to the first yet (because it was stopped), this is not
> usually apparent.

Thanks for the explanation.  I did notice sometimes the parent went into
the $SIG{CHLD} code when ctrl-Z was hit.  Presumably the child received its
TSTP first, and the parent for some reason got the CHLD from that before it
got the initial TSTP.

> If the OP really doesn't want SIGCHLDs when a child stops, he can
> install the signal handler explicitly with sigaction and SA_NOCLDSTOP
> (under systems which support that).

Oy.  That forces me to know more about the system thing than I wish I had
to know, at least for such a conceptually simple thing.  Not that that is
surprising--there are limits to how much Perl can do to insulate me. malloc
and free it does a good job of, but signals I guess are harder.


> Since one must assume that any
> number of children may have exitted when handling SIGCHLD anyway,

This is only true if one knows there is more than one child to exit, or one
is writing code that is only a small part of a larger unknown system.  If
one knows that there is only one child to exit, because only one has been
started, then one doesn't need to assume that any number greater than one
may have exited.  And if it *is* part of a larger system, than all the
other parts need to agree on how to go about doing it.  If one part does a
waitpid -1, WNOHANG and comes up with some other part's child, that could
cause problems.  Maybe there should be a way to unwait on a child, which
would store the pid and exit status away somewhere, then if the localized
$SIG{CHLD} becomes unlocalized it would fire a fake SIG_CHLD and waitpid
could return the stored away value when it is next called.

> including 0 in 'any number' is generally easier.

I find it easier to design/work around the need to ever set $SIG{CHLD} (to
anything other than the default or IGNORE) in the first place. :)

I'm perhaps fortunate in that I've usually been able to do so.  Obviously,
not all people will be lucky enough to be able get away with that.

Xho

-- 
-------------------- http://NewsReader.Com/ --------------------
The costs of publication of this article were defrayed in part by the
payment of page charges. This article must therefore be hereby marked
advertisement in accordance with 18 U.S.C. Section 1734 solely to indicate
this fact.


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

Date: Mon, 12 Nov 2007 18:06:47 -0000
From:  trillich@gmail.com
Subject: syntax question in dealing with .Net api
Message-Id: <1194890807.588286.258710@v3g2000hsg.googlegroups.com>

hi -- not sure where the best place would be to post this; please
point me elsewhere if there's another list more apropos...

we've got two apps, one in java, one in .Net, and we're trying to put
some glue together to transfer data back and forth between them:

- reading data FROM the .Net application is easy
- writing data TO the .Net application is a puzzle...

to read data from within VB, we can use syntax like VAR =
OBJ.METHOD(PARAMS) and to write fields to an object from within VB
it's also simple: OBJ.METHOD(PARAMS) = VAL.

only the read-style syntax works in exterior languages (Perl is our
platform for proof-of-concept):

$val = $obj->method("param");

but the write-style syntax needs something different:

$obj->method("param") = $expr; # no way

is there a standardized "write-to" syntax that non-VB languages can
take advantages?

$obj->method("param")->let($expr); # for example
$obj->let($expr)->method("param"); # for example
$obj->let_method("param",$expr); # for example

anybody know a FAQ or URL that'll point us in the right direction?



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

Date: Mon, 12 Nov 2007 04:32:59 -0800
From:  tmstaedt <t.mittelstaedt@cadenas.de>
Subject: WhenProblem calling perldb from a script, the current source line is not properly selected! (keywords: perl, xemacs, debug, gud, terminal, tty)
Message-Id: <1194870779.000066.275370@v2g2000hsf.googlegroups.com>

For people out there having the same problem:

The error usually sits in front of the computer, even though the perl
documentation could be a bit more explicit about this:
I just had to modify my little script to contain -emacs like:

cat /tmp/stdin-17959.log | perl -d
/buildcontrol/tinderbox/bin/processmail_builds_test.pl -emacs

A perldoc perl5db.pl tells you under 'SETTING UP THE TERMINAL' to
specify -emacs as the first option after the script.

       If there is a TTY, we have to determine who it belongs to
before
we can
       proceed. If this is a slave editor or graphical debugger
(denoted by
       the first command-line switch being '-emacs'), we shift this
off and
       set $rl to 0 (XXX ostensibly to do straight reads).



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

Date: Mon, 12 Nov 2007 13:15:32 +0000
From: Paul Marquess <paul.marquess@btinternet.com>
Subject: Re: zipping large file using Archive::Zip
Message-Id: <473851f4$0$7367$4d4eb98e@read.news.uk.uu.net>

From: Christian Winter [mailto:thepoet_nospam@arcor.de]
 
> Mark wrote:
> > I have a 16 GB file that I zipped using perl's Archive::zip module.
> > When I try to unzip this file using WinZip, it shows the "uncompressed
> > size" = 4294967295.
> >
> > Upon trying to extract this file via WinZip, the winzip program
> > deflates the file correctly to 16 GB, but then before it completes and
> > yields control to the user,  WinZip does a file size check between
> > actual decompressed size and the file information (uncompressed size)
> > stored with the Zip, and, since those don't match, it automatically it
> > considers the decompressed file as invalid and removes it from the
> > disk.
> >
> > This root cause of this problem is due to perl's ZLIB module writing
> > an incorrect header information on the zip file
> >
> > Can someone please tell me why Perl's Archive::zip module writes
> > incorrect information in the zip file header ? Are there any settings
> > that can override such behaviour?
> 
> The only way around I know of is to use a different decompression
> tool. Archive::Zip makes use of Compress::Zlib, which in turn
> calls the native zlib library. zlib, however, hasn't adopted the
> somewhat proprietary deflate64 extension which PKWare introduced
> in the pkzip sdk to make size values > 2^32 possible. In the standard
> zip format, "compressed size" and "uncompressed size" are only
> 4 bytes, therefore the value 4294967295.
>
> Unless deflate64 gets incorporated into zlib, I don't see much
> chance that Archive::Zip will be able to produce "correct" zips
> of this size. So the short solutions would be to either split
> up things into separate files, each smaller than 4 GB uncompressed,
> or use a different compression (e.g. tar/bzip2) - at least if
> dropping WinZip is a no-go.

That's not correct - you are confusing Deflate64 with Zip64. Here is the
definition of Deflate64 from the Zip definition (from
http://www.pkware.com/documents/casestudies/APPNOTE.TXT)


  Enhanced Deflating - Method 9
  -----------------------------

  The Enhanced Deflating algorithm is similar to Deflate but
  uses a sliding dictionary of up to 64K. Deflate64(tm) is supported
  by the Deflate extractor.  

To support compressed files > 2^32, your Zip implementation needs to support
Zip64. That has nothing to do with the underlying zlib implementation.

I don't think that Archive::Zip supports Zip64, but IO::Compress::Zip does.

Paul



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

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 1026
***************************************


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