[30782] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2027 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Wed Dec 3 18:09:56 2008

Date: Wed, 3 Dec 2008 15:09:14 -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, 3 Dec 2008     Volume: 11 Number: 2027

Today's topics:
    Re: FAQ 8.44 How do I tell the difference between error <brian.d.foy@gmail.com>
    Re: FAQ 8.44 How do I tell the difference between error <brian.d.foy@gmail.com>
    Re: FAQ 8.44 How do I tell the difference between error <brian.d.foy@gmail.com>
    Re: FAQ 8.44 How do I tell the difference between error <jcarlock@127.0.0.1>
        How to find cpu utilization for each process on WIndows zigzagdna@yahoo.com
    Re: Mathematica 7 compares to other languages <jon@ffconsultancy.com>
    Re: Mathematica 7 compares to other languages <xahlee@gmail.com>
    Re: Mathematica 7 compares to other languages <tmh.public@gmail.com>
    Re: Noob trying to understand simple Perl grep statemen sln@netherlands.com
    Re: Perl module for managing user groups (UNIX) (J.D. Baldwin)
    Re: Perl module for managing user groups (UNIX) <rvtol+news@isolution.nl>
    Re: perl segfault - how to troubleshoot xhoster@gmail.com
    Re: perl segfault - how to troubleshoot <james.harris.1@googlemail.com>
    Re: perl segfault - how to troubleshoot <james.harris.1@googlemail.com>
    Re: Problem with call to system(), I think. <fawaka@gmail.com>
        Problems with table position in a PDF using PDF::Table <r.ted.byers@gmail.com>
    Re: Problems with table position in a PDF using PDF::Ta sln@netherlands.com
    Re: Problems with table position in a PDF using PDF::Ta <r.ted.byers@gmail.com>
    Re: Problems with table position in a PDF using PDF::Ta <r.ted.byers@gmail.com>
    Re: Problems with table position in a PDF using PDF::Ta <jimsgibson@gmail.com>
    Re: Problems with table position in a PDF using PDF::Ta sln@netherlands.com
    Re: Problems with table position in a PDF using PDF::Ta sln@netherlands.com
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Wed, 03 Dec 2008 09:44:38 -0800
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
Message-Id: <031220080944385125%brian.d.foy@gmail.com>

In article <gh3arb$oh5$1@nntp.fujitsu-siemens.com>, Josef Moellers
<josef.moellers@fujitsu-siemens.com> wrote:

> Bill H wrote:

> IIUC:
> 
> -bash: print: command not found
> 
> Though, when I tried it, the error was
> 
> -bash: ./hello.pl: /usr/local/bin/perl: bad interpreter: No such file or 
> directory
> 
> which is not what the FAQ says. So this does not apply to all shells.

The exact message is not the point of the FAQ. IF you aren't seeing one
of Perl's warnings or errors (listed in perldiag), it might be a
problem with something that is not Perl.

When you tried it, you still got a bash error. You didn't run the same
script though. :)


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

Date: Wed, 03 Dec 2008 09:45:39 -0800
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
Message-Id: <031220080945398792%brian.d.foy@gmail.com>

In article <slrngjbh51.hm.whynot@orphan.zombinet>, Eric Pozharski
<whynot@pozharski.name> wrote:


> > which is not what the FAQ says. So this does not apply to all shells.
> 
> What even worst it doesn't apply to some environments:
> 
> Warning: unknown mime-type for "Hello World\n" -- using
> "application/octet-stream"
> Error: no such file "Hello World\n"
> 
> print (1)            - execute programs via entries in the mailcap file

Which shell is that? Notice that the answer is for a shell, not some
non-shell environment.


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

Date: Wed, 03 Dec 2008 09:46:31 -0800
From: brian d  foy <brian.d.foy@gmail.com>
Subject: Re: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
Message-Id: <031220080946311926%brian.d.foy@gmail.com>

In article
<e8517eac-fc3b-4e84-8340-e7cd2bedb108@k41g2000yqn.googlegroups.com>,
Bill H <bill@ts1000.us> wrote:


> I never even thought to look at the shebang line!

That's why I specifically pointed out the shebang line in the text. :)


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

Date: Wed, 3 Dec 2008 17:02:07 -0500
From: "Jim Carlock" <jcarlock@127.0.0.1>
Subject: Re: FAQ 8.44 How do I tell the difference between errors from the shell and perl?
Message-Id: <493701e3$0$4895$9a6e19ea@unlimited.newshosting.com>

"brian d foy" &lt;brian.d.foy at gmail.com&gt; wrote...
: Which shell is that? Notice that the answer is for a shell, not some
: non-shell environment.

There a way to accomplish something like this in a non-shell env,
mod_perl specifically? A way to catch and trap errors and I then
imagine that print can print the output to a browser.

-- 
Jim Carlock



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

Date: Wed, 3 Dec 2008 14:30:26 -0800 (PST)
From: zigzagdna@yahoo.com
Subject: How to find cpu utilization for each process on WIndows Platform  using perl
Message-Id: <18a6720f-772c-4945-af78-32a63fc4b0ec@t11g2000yqg.googlegroups.com>

I am on Windows 2000 Server. Are there any perl programs which will
show me cpu utilization of each process. I will like to schedule such
a program to find which processes are taking most of cpu (similar to
top or glance in UNIX).


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

Date: Wed, 03 Dec 2008 16:24:36 +0000
From: Jon Harrop <jon@ffconsultancy.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <L6udnQ8Si8-vL6vUnZ2dnUVZ8o6dnZ2d@posted.plusnet>

Xah Lee wrote:
> On Dec 2, 5:13 pm, Jon Harrop <j...@ffconsultancy.com> wrote:
>> The Mathematica code is 700,000x slower so a 50% improvement will be
>> uninteresting. Can you make my Mathematica code five orders of magnitude
>> faster or not?
> 
> Pay me $10 thru paypal, i'll can increase the speed so that timing is
> 0.5 of before.
> 
> Pay me $100 thru paypal, i'll try to make it timing 0.1 of before. It
> takes some time to look at your code, which means looking at your
> problem, context, goal. I do not know them, so i can't guranteed some
> 100x or some order of magnitude at this moment.
> 
> Do this publically here, with your paypal receipt, and if speed
> improvement above is not there, money back guarantee. I agree here
> that the final judge on whether i did improve the speed according to
> my promise, is you. Your risk would not be whether we disagree, but if
> i eat your money. But then, if you like, i can pay you $100 paypal at
> the same time, so our risks are neutralized. However, that means i'm
> risking my time spend on working at your code. So, i suggest $10 to me
> would be good. Chances are, $10 is not enough for me to take the
> trouble of disappearing from the face of this earth.

My example demonstrates several of Mathematica's fundamental limitations.
They cannot be avoided without improving or replacing Mathematica itself.
These issues are never likely to be addressed in Mathematica because its
users value features and not general performance.

Consequently, there is great value in combining Mathematica with performant
high-level languages like OCaml and F#. This is what the vast majority of
Mathematica users do: they use it as a glorified graph plotter.

>> > few tips:
>>
>> > • Always use Module[] unless you really have a reason to use Block[].
>>
>> Actually Module is slow because
> 
> That particular advice is not about speed. It is about lexical scoping
> vs dynamic scoping.
>
>> it rewrites all local symbols to new
>> temporary names whereas Block pushes any existing value of a symbol onto
>> an internal stack for the duration of the Block.
> 
> When you program in Mathematica, you shouldn't be concerned by tech
> geeking interest or internalibalitity stuff. Optimization is
> important, but not with choice of Block vs Module. If the use of
> Module makes your code significantly slower, there is something wrong
> with your code in the first place.

What exactly do you believe is wrong with my code?

>> In this case, Module is 30% slower.
> 
> Indeed, because somethnig is very wrong with your code.

No, that is a well-known characteristic of Mathematica's Module and it has
nothing to do with my code.

>> > • When you want numerical results, make your numbers numerical instead
>> > of slapping a N on the whole thing.
>>
>> Why?
> 
> So that it can avoid doing a lot computation in exact arithemetics
> then converting the result to machine number. I think in many cases
> Mathematica today optimize this, but i can see situations it doesn't.

That is a premature optimization that has no significant effect in this case
because all applications of N have already been hoisted.

>> > • Avoid Table[] when you really want go for speed. Try Map and Range.
>>
>> The time spent in Table is insignificant.
> 
> just like Block vs Module. It depends on how you code it. If Table is
> used in some internal loop, you pay for it.

It is insignificant in this case.

>> > • I see nowhere using Compile. Huh?
>>
>> Mathematica's Compile function has some limitations that make it
>> difficult to leverage in this case:
> 
> When you are doing intensive numerical computation, your core loop
> should be compiled.

No, such computations must be off-loaded to a more performant high-level
language implementation like OCaml or F#. With up to five orders of
magnitude performance difference, that means almost all computations.

>> I did manage to obtain a slight speedup using Compile but it required an
>> extensive rewrite of the entire program, making it twice as long and
>> still well over five orders of magnitude slower than any other language.
> 
> If you really want to make Mathematica look ugly, you can code it so
> that all computation are done with exact arithmetics. You can show the
> world how Mathematica is one googleplex times slower.

I am not trying to make Mathematica look bad. It is simply not suitable when
hierarchical solutions are preferable, e.g. FMM, BSPs, adaptive subdivision
for cosmology, hydrodynamics, geophysics, finite element materials...

The Mathematica language is perhaps the best example of what a Lisp-like
language can be good for in the real world but you cannot compare it to
modern FPLs like OCaml, Haskell, F# and Scala because it doesn't even have
a type system, let alone a state-of-the-art static type system.

Mathematica is suitable for graph plotting and for solving problems where it
provides a prepackaged solution that is a perfect fit. Even then, you can
have unexpected problems. Compute the FFT of 2^20 random machine-precision
floats and it works fine. Raise them to the power of 100 and it becomes
100x slower, at which point you might as well be writing your numerical
code in PHP.

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
http://www.ffconsultancy.com/?u


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

Date: Wed, 3 Dec 2008 13:15:11 -0800 (PST)
From: Xah Lee <xahlee@gmail.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <86bf2e29-5f8d-4349-94cf-d1561f0114e6@e1g2000pra.googlegroups.com>

On Dec 3, 8:24 am, Jon Harrop <j...@ffconsultancy.com> wrote:
> My example demonstrates several of Mathematica's fundamental limitations.

enough babble Jon.

Come flying $5 to my paypal account, and i'll give you real code,
amongest the programing tech geekers here for all to see.

I'll show, what kinda garbage you cooked up in your Mathematica code
for =E2=80=9Ccomparison=E2=80=9D.

You can actually just post your =E2=80=9Ccomparisons=E2=80=9D to =E2=80=9Cc=
omp.soft-
sys.math.mathematica=E2=80=9D, and you'll be ridiculed to death for any
reasonable judgement of claim on fairness.

> Consequently, there is great value in combining Mathematica with performa=
nt
> high-level languages like OCaml and F#. This is what the vast majority of
> Mathematica users do: they use it as a glorified graph plotter.

glorified your ass.

Yeah, NASA, Intel, NSA, ... all use Mathematica to glorify their
pictures. LOL.

> What exactly do you believe is wrong with my code?

come flies $5 to my paypal, and i'll explain further.

> I am not trying to make Mathematica look bad. It is simply not suitable w=
hen
> hierarchical solutions are preferable...

Certainly there are areas other langs are more suitable and better
than Mathematica (for example: assembly langs). But not in the ways
you painted it to peddle your F# and OCaml books.

You see Jon, you are this defensive, trollish guy, who takes every
opportunity to slight other langs that's not one of your F#, OCml that
you make a living of. In every opportunity, you injest your gribes
about static typing and other things, and thru ensuring chaos paves
the way for you to post urls to your website.

With your math and functional programing expertise and Doctor label,
it can be quite intimidating to many geekers. But when you bump into
me, i don't think you have a chance.

As a scientist, i think perhaps you should check your newsgroup
demeanor a bit? I mean, you already have a reputation of being biased.
Too much bias and peddling can be detrimental to your career, y'known?

to be sure, i still respect your expertise and in general think that a
significant percentage of tech geeker's posts in debate with you are
moronic, especially the Common Moron Lispers, and undoubtably the Java
and imperative lang slaving morons who can't grope the simplest
mathematical concepts. Throwing your Mathematica bad mouthing at me
would be a mistake.

Come, fly $5 to my paypal account. Let the challenge begin.

  Xah
=E2=88=91 http://xahlee.org/

=E2=98=84



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

Date: Wed, 3 Dec 2008 14:12:51 -0800 (PST)
From: "Thomas M. Hermann" <tmh.public@gmail.com>
Subject: Re: Mathematica 7 compares to other languages
Message-Id: <a8cdf35a-d8fd-4156-9095-81ba2f514851@z1g2000yqn.googlegroups.com>

On Dec 3, 3:15=C2=A0pm, Xah Lee <xah...@gmail.com> wrote:
> On Dec 3, 8:24 am, Jon Harrop <j...@ffconsultancy.com> wrote:
>
> > My example demonstrates several of Mathematica's fundamental limitation=
s.
>
> enough babble Jon.
>
> Come flying $5 to my paypal account, and i'll give you real code,
> amongest the programing tech geekers here for all to see.
>
> I'll show, what kinda garbage you cooked up in your Mathematica code
> for =E2=80=9Ccomparison=E2=80=9D.
>
> You can actually just post your =E2=80=9Ccomparisons=E2=80=9D to =E2=80=
=9Ccomp.soft-
> sys.math.mathematica=E2=80=9D, and you'll be ridiculed to death for any
> reasonable judgement of claim on fairness.
>
> > Consequently, there is great value in combining Mathematica with perfor=
mant
> > high-level languages like OCaml and F#. This is what the vast majority =
of
> > Mathematica users do: they use it as a glorified graph plotter.
>
> glorified your ass.
>
> Yeah, NASA, Intel, NSA, ... all use Mathematica to glorify their
> pictures. LOL.
>
> > What exactly do you believe is wrong with my code?
>
> come flies $5 to my paypal, and i'll explain further.
>
> > I am not trying to make Mathematica look bad. It is simply not suitable=
 when
> > hierarchical solutions are preferable...
>
> Certainly there are areas other langs are more suitable and better
> than Mathematica (for example: assembly langs). But not in the ways
> you painted it to peddle your F# and OCaml books.
>
> You see Jon, you are this defensive, trollish guy, who takes every
> opportunity to slight other langs that's not one of your F#, OCml that
> you make a living of. In every opportunity, you injest your gribes
> about static typing and other things, and thru ensuring chaos paves
> the way for you to post urls to your website.
>
> With your math and functional programing expertise and Doctor label,
> it can be quite intimidating to many geekers. But when you bump into
> me, i don't think you have a chance.
>
> As a scientist, i think perhaps you should check your newsgroup
> demeanor a bit? I mean, you already have a reputation of being biased.
> Too much bias and peddling can be detrimental to your career, y'known?
>
> to be sure, i still respect your expertise and in general think that a
> significant percentage of tech geeker's posts in debate with you are
> moronic, especially the Common Moron Lispers, and undoubtably the Java
> and imperative lang slaving morons who can't grope the simplest
> mathematical concepts. Throwing your Mathematica bad mouthing at me
> would be a mistake.
>
> Come, fly $5 to my paypal account. Let the challenge begin.
>
> =C2=A0 Xah
> =E2=88=91http://xahlee.org/
>
> =E2=98=84

Xah,

I'll pay $20 to see your improved version of the code. The only
references to PayPal I saw on your website were instructions to direct
the payment to xah@xahlee.org, please let me know if that is correct.

What I want in return is you to execute and time Dr. Harrop's original
code, posting the results to this thread. Then, I would like you to
post your code with the timing results to this thread as well.

By Dr. Harrop's original code, I specifically mean the code he posted
to this thread. I've pasted it below for clarity.

Jon Harrop coded a ray tracer in Mathematica:

> delta =3D Sqrt[$MachineEpsilon];
>
> RaySphere[o_, d_, c_, r_] :=3D
>   Block[{v, b, disc, t1, t2},
>     v =3D c - o;
>     b =3D v.d;
>     disc =3D Sqrt[b^2 - v.v + r^2];
>     t2 =3D b + disc;
>     If[Im[disc] !=3D 0 || t2 <=3D 0, \[Infinity],
>       t1 =3D b - disc;
>       If[t1 > 0, t1, t2]]
>     ]
>
> Intersect[o_, d_][{lambda_, n_}, Sphere[c_, r_]] :=3D
>  Block[{lambda2 =3D RaySphere[o, d, c, r]},
>   If[lambda2 >=3D lambda, {lambda, n}, {lambda2,
>     Normalize[o + lambda2 d - c]}]
>   ]
> Intersect[o_, d_][{lambda_, n_}, Bound[c_, r_, s_]] :=3D
>  Block[{lambda2 =3D RaySphere[o, d, c, r]},
>   If[lambda2 >=3D lambda, {lambda, n},
>    Fold[Intersect[o, d], {lambda, n}, s]]
>   ]
>
> neglight =3D N@Normalize[{1, 3, -2}];
>
> nohit =3D {\[Infinity], {0, 0, 0}};
>
> RayTrace[o_, d_, scene_] :=3D
>  Block[{lambda, n, g, p},
>   {lambda, n} =3D Intersect[o, d][nohit, scene];
>   If[lambda =3D=3D \[Infinity], 0,
>    g =3D n.neglight;
>    If[g <=3D 0, 0,
>     {lambda, n} =3D
>      Intersect[o + lambda d + delta n, neglight][nohit, scene];
>     If[lambda < \[Infinity], 0, g]]]
>   ]
>
> Create[level_, c_, r_] :=3D
>  Block[{obj =3D Sphere[c, r]},
>   If[level =3D=3D 1, obj,
>    Block[{a =3D 3*r/Sqrt[12], Aux},
>     Aux[x1_, z1_] :=3D Create[level - 1, c + {x1, a, z1}, 0.5 r];
>     Bound[c,
>      3 r, {obj, Aux[-a, -a], Aux[a, -a], Aux[-a, a], Aux[a, a]}]]]]
>
> scene =3D Create[1, {0, -1, 4}, 1];
>
> Main[level_, n_, ss_] :=3D
>  Block[{scene =3D Create[level, {0, -1, 4}, 1]},
>   Table[
>    Sum[
>      RayTrace[{0, 0, 0},
>       N@Normalize[{(x + s/ss/ss)/n - 1/2, (y + Mod[s, ss]/ss)/n - 1/2,
>           1}], scene], {s, 0, ss^2 - 1}]/ss^2, {y, 0, n - 1},
>    {x, 0, n - 1}]]
>
> AbsoluteTiming[Export["image.pgm", Graphics@Raster@Main[9, 512, 4]]]
>


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

Date: Wed, 03 Dec 2008 22:05:41 GMT
From: sln@netherlands.com
Subject: Re: Noob trying to understand simple Perl grep statement
Message-Id: <trtdj49t57dmtvhls8hk2lovi1l15isiv2@4ax.com>

On Tue, 2 Dec 2008 09:16:42 -0800 (PST), walterbyrd <walterbyrd@iname.com> wrote:

>This is from the perl objects book.
>
>my @required = qw(preserver sunscreen water_bottle jacket);
>my @skipper = qw(blue_shirt hat jacket preserver sunscreen);
>for my $item (@required) {
>  unless (grep $item eq $_, @skipper) { # not found in list?
>    print "skipper is missing $item.\n";
>  }
>}
>
>I don't understand this line:
>
>  unless (grep $item eq $_, @skipper)
>
>I understand that $item is each item in the @required array. I am
>guessing that the @required array is what is being grep'd. But what is
>$_ ? Is that also each item from the @required array? If so, why not
>just use the $item variable again? And what does >>$_, @skipper<<
>mean? What is with the comma? Is that supposed to mean: grep $item
>@skipper?
>
>Is this supposed to check if the skipper is missing any required item?
>Why not:
>
>  unless (grep $item @required  eq  grep $item @skipper)

I don't know what book that is but it looks like you are trying
to find the intersection of two arrays, which is a FAQ here somewhere.

Understand that grep just searches the ENTIRE array for whatever it is
you wan't to find. Each time it finds whatever it is, it collects that 
element into an array. In list/scalar context, returns list or count of
matched elements.

This is very inefficient. Whatever grep returns in the list should be
considerred read-only as well.

This from perlfunc:

 Similarly, grep returns aliases into the original list, much as a for
 loop's index variable aliases the list elements. That is, modifying an
 element of a list returned by grep (for example, in a foreach, map or
 another grep) actually modifies the element in the original list.
 This is usually something to be avoided when writing clear code.

In my opinion, this is a major fopah. Only because it aliases en masse,
as opposed to a temporary itterator.

Perl grep() is no different than itterating over an ENTIRE array and searching
for a conditional. If want array, the intermediate variable $_ (an alias for
the list element) is pushed onto a temporary array. If count, the count is tracked.
Then returned. There is no way to break out of it, it plods along, mindleslly checking
every element. This is ok when the possiblity exists on variable pattern matching,
but when searching for a single existence, not so good.

So grep would be the slowest in your case.
A quicker method is this:

for $req_item (@required)
{
	$found = 0;
	for $skip_item (@skipper)
	{
		next if ($req_item ne $skip_item);
		$found = 1;
		last;  # <- see, you wan't last, why continue?
	}
	print "skipper is missing $req_item.\n" if (!found);
}

So then, say you wan't something a little quicker.
Move up to a hash:

%skipper;
for $key (@skipper)
{
	$skipper{$key}++;
}
for $req_item (@required)
{
	if (!exists ($skipper{$req_item})
	{
		print "skipper is missing $req_item.\n"
	}
}

If you have very large arrays, with very large words,
you might even be able to set up a binary search mechanism,
half, half again, then again, and again, etc..

Good luck!

sln



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

Date: Wed, 3 Dec 2008 21:50:02 +0000 (UTC)
From: INVALID_SEE_SIG@example.com.invalid (J.D. Baldwin)
Subject: Re: Perl module for managing user groups (UNIX)
Message-Id: <gh6uua$6q6$2@reader1.panix.com>


In the previous article, Mart van de Wege
<mvdwege_public@myrealbox.com> wrote:
> How about the Debian adduser and addgroup scripts? I just took a
> short look at them, and I think they could be ported to Solaris
> without too much trouble.

Thanks.  I'll give them a look.
-- 
  _+_ From the catapult of |If anyone objects to any statement I make, I am
_|70|___:)=}- J.D. Baldwin |quite prepared not only to retract it, but also
\      /  baldwin@panix.com|to deny under oath that I ever made it.-T. Lehrer
***~~~~----------------------------------------------------------------------


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

Date: Wed, 3 Dec 2008 22:50:23 +0100
From: "Dr.Ruud" <rvtol+news@isolution.nl>
Subject: Re: Perl module for managing user groups (UNIX)
Message-Id: <gh72ml.qk.1@news.isolution.nl>

J.D. Baldwin schreef:
> I'm looking for a module or maybe some good sample code to save me
> some labor in implementing a front-end for group management.  For
> example, changing a user's primary group membership from 'foo' to
> 'bar' or removing a user from one of his secondary groups, adding him
> to a new secondary group, etc.
>
> Seems this should be pretty straightforward, it's just that it's a lot
> of code, particularly for the error-checking.  I'd rather not write it
> if I can steal-- er, "reuse" it.

You could look into LDAP, several modules and front-ends available.

-- 
Affijn, Ruud

"Gewoon is een tijger."



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

Date: 03 Dec 2008 17:06:24 GMT
From: xhoster@gmail.com
Subject: Re: perl segfault - how to troubleshoot
Message-Id: <20081203120524.957$Ni@newsreader.com>

James Harris <james.harris.1@googlemail.com> wrote:
> On 2 Dec, 16:57, xhos...@gmail.com wrote:
> >
> > I'd run:
> >
> > strace perl -c mythrename.pl
> >
> > And capture the output.  If it wasn't obvious what when wrong based on
> > the last thing before the segfault, then I'd grep out all of the file
> > opens (system libraries and such), and look at all those files to see
> > if any had changed recently.
>
> Great suggestion. I'd never heard of strace but it looks like the
> quickest way to track down what was happening. The output ends as
> follows
>
 ...
> open("/usr/lib/perl/5.8/auto/Socket/Socket.so", O_RDONLY) = 8
> read(8, "\177ELF\1\1\1\0\0\0\0\0\0\0\0\0\3\0\3\0\1\0\0\0\360\16"...,
> 512) = 512
> fstat64(8, {st_mode=S_IFREG|0644, st_size=19676, ...}) = 0
> mmap2(NULL, 22644, PROT_READ|PROT_EXEC, MAP_PRIVATE|MAP_DENYWRITE, 8,
> 0) = 0xb7c03000
> mmap2(0xb7c08000, 4096, PROT_READ|PROT_WRITE, MAP_PRIVATE|MAP_FIXED|
> MAP_DENYWRITE, 8, 0x4) = 0xb7c08000
> close(8)                                = 0
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++
> Process 18883 detached
>
> Does this mean that the segfault occurred as a result of the close(8)
> call - or at least that close() was the last system call prior to the
> fault?

No to the first--close(8) completed successfully before the segfault.
Yes to the second, close(8) was the last system call prior to the fault.
So the fault probably occurred in "user space".

I'd grep through the trace output for "open"ed .so files and see what their
mod times are.

You could use ltrace rather than strace to get even more info, but that
would be a last resort.  (Well actually, learning how to use gdb would be
my last resort.  It might do the job better, but I'd rather use the tools I
already know than learn new ones.)


> Or would the segfault have happened while executing the next call
> which is not shown? (From the man page it looks as though strace will
> trap signals and still print the failing call after a signal
> occurs ... but I'm not sure I'm reading it correctly.)

I think it would print at least something upon the initiation of the system
call, even if the call did not successful finish.  I can't guarantee it,
but that is the working assumption I would make.

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: Wed, 3 Dec 2008 13:44:00 -0800 (PST)
From: James Harris <james.harris.1@googlemail.com>
Subject: Re: perl segfault - how to troubleshoot
Message-Id: <a58fd695-2651-4d71-b438-661047342af8@h20g2000yqn.googlegroups.com>

On 3 Dec, 17:06, xhos...@gmail.com wrote:
 ...
> > Does this mean that the segfault occurred as a result of the close(8)
> > call - or at least that close() was the last system call prior to the
> > fault?
>
> No to the first--close(8) completed successfully before the segfault.
> Yes to the second, close(8) was the last system call prior to the fault.
> So the fault probably occurred in "user space".

To follow up on this, I shut the machine down and ran memtest86+ to
check the ram. That checked out OK for all tests.

On restart, however, problems with at disk partitions were found. The
problems reported included

* Block bitmap differences
* Free inode counts wrong
* (Most alarming) Buffer I/O errors from which one can only a) ignore
and b) force rewrite
* (Most relevant, perhaps, as it relates to Perl's Socket.so though
not directly):

/usr/lib/perl/5.8.8/auto/Socket/Socket.so.dpkg-tmp mod time Nov 27,
2007
 has 2 multiply-claimed blocks shared with 0 files

I spent a while running through the reported problems and then let (e2)
fsck do the rest. It took some time but on subsequent reboot the Perl
problem had gone away. I expected to have to reinstall Socket.so at
least but so far it seems to be OK now. As scripts run I'll keep an
eye on them. Hopefully they will all work now.

I've added a Linux group because this has led to other queries:

1. Is there a way to tell what file systems are corrupt while the
machine is running normally? - I.e. was Linux (Ubuntu) telling me of
the faults somewhere?
2. If it was where does it report this?
3. If it wasn't why not??? Fsck knew of faults on some of the file
systems on bootup without having to scan the disks for them. If it
knows there why not report it sooner?

Thanks to all in the Perl group for the education in debugging tools.
I'll find other uses for them.

James


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

Date: Wed, 3 Dec 2008 14:00:14 -0800 (PST)
From: James Harris <james.harris.1@googlemail.com>
Subject: Re: perl segfault - how to troubleshoot
Message-Id: <5d6d7ba8-b889-4724-a333-06c9960ccc84@h5g2000yqh.googlegroups.com>

On 3 Dec, 02:31, Ilya Zakharevich <nospam-ab...@ilyaz.org> wrote:
> [A complimentary Cc of this posting was sent to
> James Harris
> <james.harri...@googlemail.com>], who wrote in article <c7322e6e-2755-4bca-bc92-8a0a39673...@u14g2000yqg.googlegroups.com>:
>
> > Program received signal SIGSEGV, Segmentation fault.
> > [Switching to Thread 0xb7d568c0 (LWP 19771)]
> > 0xb7be0004 in boot_Socket () from /usr/lib/perl/5.8/auto/Socket/Socket.so
> > Dec  3 00:23:17 s01 kernel: [287839.008837] mythrename.pl[19643]:
> > segfault at 00000001 eip b7be5004 esp bfa104ff error 6
>
> This "at" looks very suspicious to me.  I suspect what happens is that
> code at b7be5004 is essentially jump(00000001).  (gdb allows you to
> look at the assembler, hint hint.)

Good call. The instruction at EIP was

  mov [ecx], edx

and ecx showed, not surprisingly as 1. From the disassembly ecx was
loaded a few instructions before after a call to a function.

It's moot now as I'm glad to say, the problem has gone away after
finding errors on some file systems (per separate post).

I'll monitor for a while and see if the remaining perl scripts work or
fail but hopefully that's it fixed - with me a bit more aware of
debugging facilities than I was before....

James


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

Date: 03 Dec 2008 22:53:28 GMT
From: Leon Timmermans <fawaka@gmail.com>
Subject: Re: Problem with call to system(), I think.
Message-Id: <49370de8$0$191$e4fe514c@news.xs4all.nl>

On Tue, 02 Dec 2008 17:47:31 +0000, sln wrote:
> @args = (
>   "activity.report.1.pl",
>   "\"$merchant\"",
>   $merchants_usernames{$merchant},
>   $merchants{$merchant},
>   $date_string,
>   "1>$dir\\activity.Report.$merchant.stdout",
>   "2>$dir\\activity.Report.$merchant.stderr",
> );
> 

Those last few arguments wouldn't work well. It's probably best to use 
something like IPC:Open3 here.

Regards,

Leon Timmermans


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

Date: Wed, 3 Dec 2008 13:32:18 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Problems with table position in a PDF using PDF::Table
Message-Id: <ddaf5feb-1f7a-45e2-b2bd-9db373baa82b@l42g2000yqe.googlegroups.com>

Here is the relevant part of the documentation:

($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
     $pdf,               # A PDF::API2 instance
     $page_to_start_on,  # A PDF::API2::Page instance created with
$page_to_start_on = $pdf->page();
     $data,              # 2D arrayref of text strings
     x  => $left_edge_of_table,    #X - coordinate of upper left
corner
     w  => 570, # width of table.
     start_y => $initial_y_position_on_first_page,
     next_y  => $initial_y_position_on_every_new_page,
     start_h => $table_height_on_first_page,
     next_h  => $table_height_on_every_new_page,
 ...
}

Notice the specification of the meaning of next_y!

Here is what I have in my code:

  ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
                 $pdf,
                 $page,
                 \@table2,
                 x=>$x,
                 w=>555,
                 start_y=>$y,
                 next_y=>$900,
                 start_h=> 250,
                 next_h=>500,
# optional parameters
                 padding =>2,
                 header_props=>$hdr_props,
                 column_props=>$col_propsM2,
  );

No matter what values I give next_y or next_h, the continuation of the
table on the second page is ALWAYS placed in the middle of the page.

What I would really like to happen is to always have the continuation
of the table start at the top of the next page and to fill the page if
there is sufficient data.  However, I have yet to find the magic
required to make that happen in the documentation for PDF::Table (the
package I am using for this).

Can anyone tell me either what I missed (is there relevant information
elsewhere than the man page for PDF::Table) or how I might fix or work
around this?

Thanks

Ted


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

Date: Wed, 03 Dec 2008 22:25:29 GMT
From: sln@netherlands.com
Subject: Re: Problems with table position in a PDF using PDF::Table
Message-Id: <rg1ej4lf9prascnlc481pi0thbcoilk5ti@4ax.com>

On Wed, 3 Dec 2008 13:32:18 -0800 (PST), Ted Byers <r.ted.byers@gmail.com> wrote:

>Here is the relevant part of the documentation:
>
>($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
>     $pdf,               # A PDF::API2 instance
>     $page_to_start_on,  # A PDF::API2::Page instance created with
>$page_to_start_on = $pdf->page();
>     $data,              # 2D arrayref of text strings
>     x  => $left_edge_of_table,    #X - coordinate of upper left
>corner
>     w  => 570, # width of table.
>     start_y => $initial_y_position_on_first_page,
>     next_y  => $initial_y_position_on_every_new_page,
>     start_h => $table_height_on_first_page,
>     next_h  => $table_height_on_every_new_page,
>...
>}
>
>Notice the specification of the meaning of next_y!
>
>Here is what I have in my code:
>
>  ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
>                 $pdf,
>                 $page,
>                 \@table2,
>                 x=>$x,
>                 w=>555,
>                 start_y=>$y,
>                 next_y=>$900,
>                 start_h=> 250,
>                 next_h=>500,
># optional parameters
>                 padding =>2,
>                 header_props=>$hdr_props,
>                 column_props=>$col_propsM2,
>  );
>
I don't know this package. But, do you notice that
you have an ODD number of parameters passed to
 $pdftable->table ??

Usually, a package writer parses such input in pairs.
Unless say after \@table2, he is taking optional @args in pairs.
ie:

sub table
{
	my ($self,$pdf,$page,$arrayref,@args) = @_;
}


sln



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

Date: Wed, 3 Dec 2008 14:25:42 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: Problems with table position in a PDF using PDF::Table
Message-Id: <a92a01ef-7319-454b-ac7a-54d420ca8054@41g2000yqf.googlegroups.com>

On Dec 3, 4:32=A0pm, Ted Byers <r.ted.by...@gmail.com> wrote:
> Here is the relevant part of the documentation:
>
> ($end_page, $pages_spanned, $table_bot_y) =3D $pdftable->table(
> =A0 =A0 =A0$pdf, =A0 =A0 =A0 =A0 =A0 =A0 =A0 # A PDF::API2 instance
> =A0 =A0 =A0$page_to_start_on, =A0# A PDF::API2::Page instance created wit=
h
> $page_to_start_on =3D $pdf->page();
> =A0 =A0 =A0$data, =A0 =A0 =A0 =A0 =A0 =A0 =A0# 2D arrayref of text string=
s
> =A0 =A0 =A0x =A0=3D> $left_edge_of_table, =A0 =A0#X - coordinate of upper=
 left
> corner
> =A0 =A0 =A0w =A0=3D> 570, # width of table.
> =A0 =A0 =A0start_y =3D> $initial_y_position_on_first_page,
> =A0 =A0 =A0next_y =A0=3D> $initial_y_position_on_every_new_page,
> =A0 =A0 =A0start_h =3D> $table_height_on_first_page,
> =A0 =A0 =A0next_h =A0=3D> $table_height_on_every_new_page,
> ...
>
> }
>
> Notice the specification of the meaning of next_y!
>
> Here is what I have in my code:
>
> =A0 ($end_page, $pages_spanned, $table_bot_y) =3D $pdftable->table(
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$pdf,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0$page,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0\@table2,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0x=3D>$x,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0w=3D>555,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0start_y=3D>$y,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0next_y=3D>$900,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0start_h=3D> 250,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0next_h=3D>500,
> # optional parameters
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0padding =3D>2,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0header_props=3D>$hdr_props,
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0column_props=3D>$col_propsM2,
> =A0 );
>
> No matter what values I give next_y or next_h, the continuation of the
> table on the second page is ALWAYS placed in the middle of the page.
>
> What I would really like to happen is to always have the continuation
> of the table start at the top of the next page and to fill the page if
> there is sufficient data. =A0However, I have yet to find the magic
> required to make that happen in the documentation for PDF::Table (the
> package I am using for this).
>
> Can anyone tell me either what I missed (is there relevant information
> elsewhere than the man page for PDF::Table) or how I might fix or work
> around this?
>
> Thanks
>
> Ted

A new observation related to this.

On increasing the amount of data to stress the code, and playing with
the mouse wheel, I noticed that the top of the table in question when
it is continued on the second page is precisely in line with the top
of the table as it appears on the first page, almost as if the next_y
parameter is ignored.

While I wait for a response, I will look into the code for PDF::Table,
much as I hate to debug someone else's code, to see if I can spot a
problem there.

I will report back here if I find something.

Cheers

Ted


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

Date: Wed, 3 Dec 2008 14:33:31 -0800 (PST)
From: Ted Byers <r.ted.byers@gmail.com>
Subject: Re: Problems with table position in a PDF using PDF::Table
Message-Id: <4d1aec47-ae4a-4d42-9692-38c0e69b052c@k36g2000yqe.googlegroups.com>

On Dec 3, 5:25=A0pm, s...@netherlands.com wrote:
> On Wed, 3 Dec 2008 13:32:18 -0800 (PST), Ted Byers <r.ted.by...@gmail.com=
> wrote:
> >Here is the relevant part of the documentation:
>
> >($end_page, $pages_spanned, $table_bot_y) =3D $pdftable->table(
> > =A0 =A0 $pdf, =A0 =A0 =A0 =A0 =A0 =A0 =A0 # A PDF::API2 instance
> > =A0 =A0 $page_to_start_on, =A0# A PDF::API2::Page instance created with
> >$page_to_start_on =3D $pdf->page();
> > =A0 =A0 $data, =A0 =A0 =A0 =A0 =A0 =A0 =A0# 2D arrayref of text strings
> > =A0 =A0 x =A0=3D> $left_edge_of_table, =A0 =A0#X - coordinate of upper =
left
> >corner
> > =A0 =A0 w =A0=3D> 570, # width of table.
> > =A0 =A0 start_y =3D> $initial_y_position_on_first_page,
> > =A0 =A0 next_y =A0=3D> $initial_y_position_on_every_new_page,
> > =A0 =A0 start_h =3D> $table_height_on_first_page,
> > =A0 =A0 next_h =A0=3D> $table_height_on_every_new_page,
> >...
> >}
>
> >Notice the specification of the meaning of next_y!
>
> >Here is what I have in my code:
>
> > =A0($end_page, $pages_spanned, $table_bot_y) =3D $pdftable->table(
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $pdf,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 $page,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 \@table2,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 x=3D>$x,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 w=3D>555,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 start_y=3D>$y,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 next_y=3D>$900,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 start_h=3D> 250,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 next_h=3D>500,
> ># optional parameters
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 padding =3D>2,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 header_props=3D>$hdr_props,
> > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 column_props=3D>$col_propsM2,
> > =A0);
>
> I don't know this package. But, do you notice that
> you have an ODD number of parameters passed to
> =A0$pdftable->table ??
>
> Usually, a package writer parses such input in pairs.
> Unless say after \@table2, he is taking optional @args in pairs.
> ie:
>
> sub table
> {
> =A0 =A0 =A0 =A0 my ($self,$pdf,$page,$arrayref,@args) =3D @_;
>
> }
>
> sln- Hide quoted text -
>
> - Show quoted text -

Yes, but that is the way he documents this package to work.

It seems clear to me that the first three arguments are required in
the order provided and that the remaining arguments are held in a
hash.  His documentation wouldn't make sense otherwise.  While I have
not yet looked at his code, my guess is that he strips off the first
three arguments and then places the remaining arguments in a hash.

Thanks

Ted


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

Date: Wed, 03 Dec 2008 14:57:38 -0800
From: Jim Gibson <jimsgibson@gmail.com>
Subject: Re: Problems with table position in a PDF using PDF::Table
Message-Id: <031220081457383129%jimsgibson@gmail.com>

In article
<ddaf5feb-1f7a-45e2-b2bd-9db373baa82b@l42g2000yqe.googlegroups.com>,
Ted Byers <r.ted.byers@gmail.com> wrote:


> Here is what I have in my code:
> 
>   ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
>                  $pdf,
>                  $page,
>                  \@table2,
>                  x=>$x,
>                  w=>555,
>                  start_y=>$y,
>                  next_y=>$900,

Is that really '$900' in your code? That is probably undefined (unless
you have a very long regular expression in your code.)

>                  start_h=> 250,
>                  next_h=>500,
> # optional parameters
>                  padding =>2,
>                  header_props=>$hdr_props,
>                  column_props=>$col_propsM2,
>   );

-- 
Jim Gibson


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

Date: Wed, 03 Dec 2008 23:06:06 GMT
From: sln@netherlands.com
Subject: Re: Problems with table position in a PDF using PDF::Table
Message-Id: <r04ej4tlbn82p9nobfi03h5krf1q54ov4u@4ax.com>

On Wed, 3 Dec 2008 14:33:31 -0800 (PST), Ted Byers <r.ted.byers@gmail.com> wrote:

>On Dec 3, 5:25 pm, s...@netherlands.com wrote:
>> On Wed, 3 Dec 2008 13:32:18 -0800 (PST), Ted Byers <r.ted.by...@gmail.com> wrote:
>> >Here is the relevant part of the documentation:
>>
[snip]
>Yes, but that is the way he documents this package to work.
>
>It seems clear to me that the first three arguments are required in
>the order provided and that the remaining arguments are held in a
>hash.  His documentation wouldn't make sense otherwise.  While I have
>not yet looked at his code, my guess is that he strips off the first
>three arguments and then places the remaining arguments in a hash.
>
Or, splice the array by 2's, which is easier to control for name
manipulation and to aviod even'es hash requirements.

sln



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

Date: Wed, 03 Dec 2008 23:07:41 GMT
From: sln@netherlands.com
Subject: Re: Problems with table position in a PDF using PDF::Table
Message-Id: <794ej4lbm6tjn00cp9h3spmdm8ol7o4gv8@4ax.com>

On Wed, 03 Dec 2008 14:57:38 -0800, Jim Gibson <jimsgibson@gmail.com> wrote:

>In article
><ddaf5feb-1f7a-45e2-b2bd-9db373baa82b@l42g2000yqe.googlegroups.com>,
>Ted Byers <r.ted.byers@gmail.com> wrote:
>
>
>> Here is what I have in my code:
>> 
>>   ($end_page, $pages_spanned, $table_bot_y) = $pdftable->table(
>>                  $pdf,
>>                  $page,
>>                  \@table2,
>>                  x=>$x,
>>                  w=>555,
>>                  start_y=>$y,
>>                  next_y=>$900,
>
>Is that really '$900' in your code? That is probably undefined (unless
>you have a very long regular expression in your code.)
>
>>                  start_h=> 250,
>>                  next_h=>500,
>> # optional parameters
>>                  padding =>2,
>>                  header_props=>$hdr_props,
>>                  column_props=>$col_propsM2,
>>   );
$900, holy cow..



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

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


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