[32843] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 4109 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Sun Jan 5 14:09:36 2014

Date: Sun, 5 Jan 2014 11:09:04 -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           Sun, 5 Jan 2014     Volume: 11 Number: 4109

Today's topics:
        Apache log page counter? <tuxedo@mailinator.com>
        Help with understanding references to subroutines <daves@orpheusmail.co.uk>
    Re: Help with understanding references to subroutines <rweikusat@mobileactivedefense.com>
    Re: Help with understanding references to subroutines <rweikusat@mobileactivedefense.com>
    Re: Help with understanding references to subroutines <hjp-usenet3@hjp.at>
    Re: Help with understanding references to subroutines <ben@morrow.me.uk>
    Re: Help with understanding references to subroutines <jurgenex@hotmail.com>
    Re: Question about language setting <kst-u@mib.org>
    Re: Question about language setting <hjp-usenet3@hjp.at>
    Re: Question about language setting <ben@morrow.me.uk>
        sudden segmentation faults.  help? (hymie!)
    Re: sudden segmentation faults.  help? <ben@morrow.me.uk>
    Re: sudden segmentation faults.  help? (hymie!)
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Sun, 5 Jan 2014 19:47:22 +0100
From: Tuxedo <tuxedo@mailinator.com>
Subject: Apache log page counter?
Message-Id: <lac9bq$e6p$1@news.albasani.net>

I would like to implement a web page counter to measure 'unique' visitors 
p/page and p/IP in 24 hour cycles, so if several visits to a particular 
page comes from a same IP in a 24 hours time frame, it counts as one 
visitor to that page. While if the same visitor comes back to the same 
page, say 25 hours later counting from his previous IP and page count, the 
count can increment for that page again. In reality, this may represent a 
repeat visitor or another visitor having been assigned the same IP. 

Depending on type of web traffic and overall rotating IPs cycles by 
different net connection service providers, this type of solution may at 
best provide a highly approximate overview of a number of unique visitors.

The source data is rotating Apache access logs in the format:
192.114.71.13 - - [05/Jan/2014:19:10:19 +0100] "GET / HTTP/1.1" 302 186 
"http:.../ref_if_transmitted.html" "Mozilla, browser version etc...."

Also, I prefer to avoid external services, free or otherwise, which do data 
collection or simply isn't what I need, not to mention they can slow a site 
down while connecting to their external servers unnecessarily sharing 
visitor data to third-parties using cookies etc., which in all defeats the 
general purpose of facilitating a positive user experience that should 
ideally help build up traffic in the first place....

Any ideas, including home-grown open-source perl based logfile processing 
solutions, would be most welcome!

Many thanks,
Tuxedo


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

Date: Sat, 04 Jan 2014 19:40:24 +0000 (GMT)
From: Dave Stratford <daves@orpheusmail.co.uk>
Subject: Help with understanding references to subroutines
Message-Id: <53c4e0579bdaves@orpheusmail.co.uk>

Hi folks,

I'm doing a short online tutorial on perl to try and get my skill level up
from novice to whatever the next level might be!!

So far it's all been relatively straight forwards, except that I've got to
a lesson on references to subroutines.

I can cope, after a fashion, with references to arrays, hashes, and even
scalars, but I can't bend my mind around references to subroutines.

This is the entire tutorial page:

========================== >8 ==========================

Reference to a subroutine

Up to now we've devoted our efforts to understanding and making use of
references to scalar, array and hash variables. In this section we show
that you can have references to subroutines as well. With this, we can
pass subroutines around as variables and arguments to other subroutines.
The syntax is slightly different, but hopefully the next exercise will
make it all clear. 

Just going through the motions:

1. Two ways of creating a reference to a scalar:

a) Start with a scalar

my $scalar = 'Foo';
my $rs_foo = \$scalar;


b) Directly create a reference to an anonymous scalar

my $rs_foo = \'Foo';


2. Two ways of creating a reference to an array:

a) Start with an array

my @arr = (1,2,3);
my $r_arr = \@arr;


b) Directly create a reference to an anonymous array

my $r_arr = [1,2,3];


3. Two ways of creating a reference to a hash:

a) Start with a hash

my %hash = ( foo => 1, bar => 2 );
my $r_hash = \%hash;


b) Directly create a reference to an anonymous hash

my $r_hash = { foo => 1, bar => 2 };


Finally,

4. Two ways to create a reference to a subroutine:

a) Start with a subroutine

sub foo { return 'bar'; }
my $r_sub = \&foo;


b) Directly create a reference to an anonymous subroutine

my $r_sub = sub { return 'bar'; };

In either case to call it, just type

&$r_sub();

Notes:

    For a more in-depth discussion, see IP Ch7
    If you progress to using Perl for web development, you will use
subroutine references extensively for implementing the website controller
using frameworks such as Catalyst or Dancer.

Exercise

Save the code below as call_subroutine_reference and where it says ###
insert code here ### get the subroutine reference from the arguments, run
it and store the returned value into $retval

#!/usr/bin/perl
 
use strict;
use warnings;
use Data::Dump 'pp';
use feature 'say';
 
my $r_foo = sub { return "foo"; };
my $r_bar = sub { return {this => 1, that => 2}; };
 
sub call_sub {
 
    ### Insert code here ###
    # $retval is what the subroutine returns
 
    return $retval;
}
 
say 'r_foo returns '.pp(call_sub($r_foo));
say 'r_bar returns '.pp(call_sub($r_bar));


The output should be:

r_foo returns "foo"
r_bar returns { that => 2, this => 1 }

========================== 8< ==========================

From this I created the subroutine code as:

sub call_sub {
    my $data = shift;
    my $retval;
    if ($data == $r_foo)
    {
       $retval = &$r_foo;
    }
    else
    {
       $retval = &$r_bar;
    }
 
    return $retval;
}

When I run it, I get exactly what I want to get, but it seems to me to be
an excessively awkward way to decide which of two subroutines you want to
call.

What is the purpose of the subroutine reference?
Why does call_sub even need to exist?
I cannot see the purpose of passing a reference to a subroutine around,
why could the code not simply say:

say 'r_foo returns '. &$r_foo;
say 'r_bar returns '. &$r_bar;

After all, if you are calling call_sub($r_foo) then you must /know/ you
are calling r_foo.

Even, why have them as references to anonymous subroutines in the first
place?

I'm obviously missing something fairly fundamental here, so any help to
relieve the pressure on my poor suffering brain would be most appreciated.

Any idea what IP chapter 7 might refer to? I used to work for the UKIPO,
so to me IP (without 'address') means Intellectual Property.

I was going to ask why Catalyst or Dancer would /require/ the use of
references to subroutines, but I think my brain already hurts enough as it
is.

Dave

-- 
Dave Stratford - ZFCB
http://daves.orpheusweb.co.uk/



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

Date: Sat, 04 Jan 2014 20:37:11 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Help with understanding references to subroutines
Message-Id: <87vbxzeb60.fsf@sable.mobileactivedefense.com>

Dave Stratford <daves@orpheusmail.co.uk> writes:

[...]

> 4. Two ways to create a reference to a subroutine:
>
> a) Start with a subroutine
>
> sub foo { return 'bar'; }
> my $r_sub = \&foo;
>
>
> b) Directly create a reference to an anonymous subroutine
>
> my $r_sub = sub { return 'bar'; };
>
> In either case to call it, just type
>
> &$r_sub();

Calling a subroutine via & has the two 'special effects' of bypassing
any prototype checking and reusing the current @_ for its
arguments. This is mostly useful for 'call-forwarding'. Assuming that
$r_sub contains a sub reference, it can also be invoked as

$r_sub->(arg0, arg1, ...)

[...]


[...]

> When I run it, I get exactly what I want to get, but it seems to me to be
> an excessively awkward way to decide which of two subroutines you want to
> call.
>
> What is the purpose of the subroutine reference?

Contrived example:

-------------
my %ops = (
	   '+' => sub { $_[0] + $_[1]},
	   '-' => sub { $_[0] - $_[1]},
	   '*' => sub { $_[0] * $_[1]},
	   '/' => sub { $_[0] / $_[1]},
	   '^' => sub { $_[0] ** $_[1]});

sub calc
{
    my ($op, $a, $b) = @_;
    printf("The result is %f\n", $op->($a, $b));
}

my $in;

while (1) {
    print("Enter a term: ");
    
    $in = <STDIN>;
    $in // last;

    $in =~ /^\s*(\d+)\s*([-+^*\/])\s*(\d+)\s*$/ or do {
	print STDERR ("\tWTF??\n\n");
	next;
    };

    calc($ops{$2}, $1, $3);
}

print("\n");
-------------

This reads terms of the form

<integer> <operator> <integer>

(operators are +, -, *, / an ^) from stdin, computes the result and
prints it.


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

Date: Sat, 04 Jan 2014 20:49:53 +0000
From: Rainer Weikusat <rweikusat@mobileactivedefense.com>
Subject: Re: Help with understanding references to subroutines
Message-Id: <871u0no4jy.fsf@sable.mobileactivedefense.com>

Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:

[...]

>     $in =~ /^\s*(\d+)\s*([-+^*\/])\s*(\d+)\s*$/ or do {
> 	print STDERR ("\tWTF??\n\n");
> 	next;
>     };
>
>     calc($ops{$2}, $1, $3);

Additional remark: Calling a function like this is usually not a good
idea because the next successful regex-match will change the values of
$1, $2 and $3, thus possibly changing the arguments to the function as
unintended side effect (in case the called subroutine accesses its
arguments via @_ instead of copying them into my-variables).


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

Date: Sat, 4 Jan 2014 22:06:04 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Help with understanding references to subroutines
Message-Id: <slrnlcgtts.l34.hjp-usenet3@hrunkner.hjp.at>

On 2014-01-04 19:40, Dave Stratford <daves@orpheusmail.co.uk> wrote:
> Exercise
>
> Save the code below as call_subroutine_reference and where it says ###
> insert code here ### get the subroutine reference from the arguments, run
> it and store the returned value into $retval
>
> #!/usr/bin/perl
>  
> use strict;
> use warnings;
> use Data::Dump 'pp';
> use feature 'say';
>  
> my $r_foo = sub { return "foo"; };
> my $r_bar = sub { return {this => 1, that => 2}; };
>  
> sub call_sub {
>  
>     ### Insert code here ###
>     # $retval is what the subroutine returns
>  
>     return $retval;
> }
>  
> say 'r_foo returns '.pp(call_sub($r_foo));
> say 'r_bar returns '.pp(call_sub($r_bar));
>
>
> The output should be:
>
> r_foo returns "foo"
> r_bar returns { that => 2, this => 1 }
>
>========================== 8< ==========================
>
> From this I created the subroutine code as:
>
> sub call_sub {
>     my $data = shift;
>     my $retval;
>     if ($data == $r_foo)
>     {
>        $retval = &$r_foo;
>     }
>     else
>     {
>        $retval = &$r_bar;
>     }
>  
>     return $retval;
> }
>
> When I run it, I get exactly what I want to get, but it seems to me to be
> an excessively awkward way to decide which of two subroutines you want to
> call.

Yes, that's awkward, and missing the point. 

Let's simplify it a bit:

> sub call_sub {
>     my $data = shift;
>     my $retval;
>     if ($data == $r_foo)
>     {
>        $retval = &$r_foo;

Here $data == $r_foo, so we can replace this line with

	$retval = &$data;

>     }
>     else
>     {
>        $retval = &$r_bar;

And here $data == $r_bar, so we can replace this line with

	$retval = &$data;

>     }
>  
>     return $retval;
> }

So, now both branches are identical and we can remove the if:

sub call_sub {
    my $data = shift;
    my $retval;
    $retval = &$data;
    return $retval;
}

Looks a lot simpler, doesn't it? And also more general: call_sub() can
now call ANY subroutine passed to it, not just $r_foo and $r_bar. 


> What is the purpose of the subroutine reference?

I'm not sure if I understand the question. The purpose of subroutine
references is to refer to subroutines, so that they can be stored in
variables, passed as arguments to other functions, etc.


> Why does call_sub even need to exist?

To show you how to pass subroutine references around and how to call
them. It's example code. It doesn't do anything useful.

> I cannot see the purpose of passing a reference to a subroutine around,
> why could the code not simply say:
>
> say 'r_foo returns '. &$r_foo;
> say 'r_bar returns '. &$r_bar;

You could do that. You could also use named subs and call those. But
then there wouldn't be any references involved and it wouldn't be much
use as an example. 


> After all, if you are calling call_sub($r_foo) then you must /know/ you
> are calling r_foo.

Yes, but only where you call call_sub(). The function call_sub() itself
doesn't know anything about $r_foo. It just knows that it gets a
subroutine reference which it is supposed to call.

> I'm obviously missing something fairly fundamental here, so any help to
> relieve the pressure on my poor suffering brain would be most appreciated.

You are probably missing it because the example is so useless. In a real
programm call_sub() would do something interesting, not just call a sub
and return the result.

For example, in the File::Find module, the find function recursively
searches a directory tree and calls the function for every directory
entry it finds. Or the builtin sort calls the comparison function for
each pair of elements it wants to compare (it's just a block, not a sub,
but that's just syntactic sugar). 

Being able to use a function reference in these cases is very useful:
You don't have to rewrite directory walking code just because you want
to do something different to the files it finds - just pass in a
different "wanted" function. You don't have to rewrite sort just because
you want to sort by different criteria - just pass in a different
comparison function.

> Any idea what IP chapter 7 might refer to? 

http://shop.oreilly.com/product/9780596102067.do I guess.

> I was going to ask why Catalyst or Dancer would /require/ the use of
> references to subroutines, but I think my brain already hurts enough as it
> is.

Because they need to call the functions you provide. It's very similar
to what File::Find or sort do: They provide a framework, but you need to
fill in the details.

	hp

-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel


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

Date: Sat, 4 Jan 2014 23:00:41 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Help with understanding references to subroutines
Message-Id: <pdgmpa-00v.ln1@anubis.morrow.me.uk>


Quoth "Peter J. Holzer" <hjp-usenet3@hjp.at>:
> On 2014-01-04 19:40, Dave Stratford <daves@orpheusmail.co.uk> wrote:
> >
> > sub call_sub {
> >     my $data = shift;
> >     my $retval;
> >     if ($data == $r_foo)
> >     {
> >        $retval = &$r_foo;
> >     }
> >     else
> >     {
> >        $retval = &$r_bar;
> >     }
> >  
> >     return $retval;
> > }
> >
> > When I run it, I get exactly what I want to get, but it seems to me to be
> > an excessively awkward way to decide which of two subroutines you want to
> > call.
> 
> Yes, that's awkward, and missing the point. 
> 
> Let's simplify it a bit:
> 
> > sub call_sub {
> >     my $data = shift;
> >     my $retval;
> >     if ($data == $r_foo)
> >     {
> >        $retval = &$r_foo;
> 
> Here $data == $r_foo, so we can replace this line with
> 
> 	$retval = &$data;

I know this is taken from the tutorial mentioned, but we (TINW) should
really be encouraging people to call subrefs like this

    $retval = $data->();

As Rainer pointed out, the &-form for calling subs can have
side-effects; in the particular case of calling through a reference,
prototypes don't apply, but if you write the call as

    $retval = &$data;

rather than

    $retval = &$data();

$data will inherit the current @_, which is obviously a Bad Thing. This
mistake is impossible to make with the $data->() form of call (and it
matches nicely with the $ref->{} forms of array/hash dereference).

[...]
> > What is the purpose of the subroutine reference?
> 
> I'm not sure if I understand the question. The purpose of subroutine
> references is to refer to subroutines, so that they can be stored in
> variables, passed as arguments to other functions, etc.

The concept of higher-order programming (that subs can be treated as
data values) is not a trivial one. It's not entirely surprising the OP
is having trouble with it. The most convenient example for explaining
the point of subrefs is using them for callbacks, like the File::Find
example you give below.

> > I'm obviously missing something fairly fundamental here, so any help to
> > relieve the pressure on my poor suffering brain would be most appreciated.
> 
> You are probably missing it because the example is so useless. In a real
> programm call_sub() would do something interesting, not just call a sub
> and return the result.
> 
> For example, in the File::Find module, the find function recursively
> searches a directory tree and calls the function for every directory
> entry it finds. Or the builtin sort calls the comparison function for
> each pair of elements it wants to compare (it's just a block, not a sub,
> but that's just syntactic sugar). 

[It's not, actually; sort blocks are rather more complicated than a
simple sub ref.]

Ben



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

Date: Sat, 04 Jan 2014 17:10:48 -0800
From: Jürgen Exner <jurgenex@hotmail.com>
Subject: Re: Help with understanding references to subroutines
Message-Id: <fsahc9lau7s5n6a1mmc32drlmru6hs9ji1@4ax.com>

Dave Stratford <daves@orpheusmail.co.uk> wrote:
[...]
>When I run it, I get exactly what I want to get, but it seems to me to be
>an excessively awkward way to decide which of two subroutines you want to
>call.

In that contrived example, yes.

>What is the purpose of the subroutine reference?
>Why does call_sub even need to exist?
>I cannot see the purpose of passing a reference to a subroutine around,
>
>After all, if you are calling call_sub($r_foo) then you must /know/ you
>are calling r_foo.
>
>Even, why have them as references to anonymous subroutines in the first
>place?
>
>I'm obviously missing something fairly fundamental here, so any help to
>relieve the pressure on my poor suffering brain would be most appreciated.

Your are right, for simple examples references to functions are rarely
all that useful. However they begin to make a lot of sense as soon as
you are starting to talk about higher order functions, i.e. functions
that take functions as arguments. They are extremely powerful although
many developers never understand them. Some examples (free-style
notation):

filter (aka grep): takes a list of items and a custom function which
returns true or false for each item of the list; returns the list of
items for which the custom function yields true.

map: takes a list of items and a custom function; this function is
applied to each item in the list

reduce: takes a list of items L and custom function OP; then this
operation is applied between all items of the list until only a single
element is left
	L[0] OP L[1] OP L[2] OP L[3] ..... L[n]
If OP happens be + then you get the sum of all elements, if it is * then
you get the product of all elements, if it is a custom function
returning the larger of both arguments then you get the maximum value of
the list, etc, etc.

sort: takes a list of items and a custom function which for any two
items decides if the left item or the right item is larger or if both
are equal.

The beauty of these HOFs is that they don't care about the type of item.
They are generic and will work on lists of numbers, lists of strings,
lists of personel records, lists of whatever, because the handling of
the actual item is left to the custom function which is user-supplied as
an argument. And therefore I don't need to implement 5 dozen sort
functions only because I need to sort lists of 5 dozen different item
types.

jue


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

Date: Sat, 04 Jan 2014 19:07:30 -0800
From: Keith Thompson <kst-u@mib.org>
Subject: Re: Question about language setting
Message-Id: <ln8uuv5dot.fsf@nuthaus.mib.org>

Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
> Keith Thompson <kst-u@mib.org> writes:
[...]
>> setlocale() returns a char* that's either a pointer to a string (if it
>> succeeded), or a null pointer (if it failed).  It's probably worth
>> adding code to check for this rather than just depending on the output
>> of printf to change.  (On my system, the first setlocale() call fails
>> because I don't have any German locales installed.)
>
> Neither had I[*]. But
>
> setlocale(LC_NUMERIC, "de_DE");
>
> is supposed to switch to 'Germanly formatted numerals' (with apologies
> to people who care about grammer :-) and if it can't because the
> necessary information is not available, it didn't work as it was
> supposed to.

According to what standard?  ISO C only defines the "C" locale; others
are implementation-defined.  POSIX adds "POSIX" as a synonym for "C".

[...]

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
Working, but not speaking, for JetHead Development, Inc.
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"


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

Date: Sun, 5 Jan 2014 12:44:51 +0100
From: "Peter J. Holzer" <hjp-usenet3@hjp.at>
Subject: Re: Question about language setting
Message-Id: <slrnlcihdk.v7o.hjp-usenet3@hrunkner.hjp.at>

On 2014-01-05 03:07, Keith Thompson <kst-u@mib.org> wrote:
> Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
>> Neither had I[*]. But
>>
>> setlocale(LC_NUMERIC, "de_DE");
>>
>> is supposed to switch to 'Germanly formatted numerals'
>
> According to what standard?  ISO C only defines the "C" locale; others
> are implementation-defined.  POSIX adds "POSIX" as a synonym for "C".

The Open Group Base Specification Issue 7; IEEE Std 1003.1, 2013 Edition:

| [XSI] [Option Start]
| If the locale value has the form:
| 
| language[_territory][.codeset]
| 
| it refers to an implementation-provided locale, where settings of
| language, territory, and codeset are implementation-defined.
| 
| LC_COLLATE, LC_CTYPE, LC_MESSAGES, LC_MONETARY, LC_NUMERIC, and LC_TIME
| are defined to accept an additional field @ modifier, which allows the
| user to select a specific instance of localization data within a single
| category (for example, for selecting the dictionary as opposed to the
| character ordering of data). The syntax for these environment variables
| is thus defined as:
| 
| [language[_territory][.codeset][@modifier]]
| 
| For example, if a user wanted to interact with the system in French, but
| required to sort German text files, LANG and LC_COLLATE could be defined
| as:
| 
| LANG=Fr_FR
| LC_COLLATE=De_DE
| 
| This could be extended to select dictionary collation (say) by use of
| the @ modifier field; for example:
| 
| LC_COLLATE=De_DE@dict
| [Option End]

So it's an optional extension to POSIX. 

The format for the language, territory and codeset specifiers doesn't
seem to be specified, but the examples suggest ISO 639-1 for languages
and ISO-3166 for territories, and I think pretty much all current
unix-like systems follow these examples.

	hp

[1] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap08.html#tag_08


-- 
   _  | Peter J. Holzer    | Fluch der elektronischen Textverarbeitung:
|_|_) |                    | Man feilt solange an seinen Text um, bis
| |   | hjp@hjp.at         | die Satzbestandteile des Satzes nicht mehr
__/   | http://www.hjp.at/ | zusammenpaßt. -- Ralph Babel


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

Date: Sun, 5 Jan 2014 16:25:43 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: Question about language setting
Message-Id: <7ldopa-j6a1.ln1@anubis.morrow.me.uk>


Quoth "Peter J. Holzer" <hjp-usenet3@hjp.at>:
> On 2014-01-05 03:07, Keith Thompson <kst-u@mib.org> wrote:
> > Rainer Weikusat <rweikusat@mobileactivedefense.com> writes:
> >> Neither had I[*]. But
> >>
> >> setlocale(LC_NUMERIC, "de_DE");
> >>
> >> is supposed to switch to 'Germanly formatted numerals'
> >
> > According to what standard?  ISO C only defines the "C" locale; others
> > are implementation-defined.  POSIX adds "POSIX" as a synonym for "C".
> 
> The Open Group Base Specification Issue 7; IEEE Std 1003.1, 2013 Edition:
> 
> | [XSI] [Option Start]
> | If the locale value has the form:
> | 
> | language[_territory][.codeset]
> | 
> | it refers to an implementation-provided locale, where settings of
> | language, territory, and codeset are implementation-defined.

This says neither that de_DE must be supported nor that it must refer to
a locale using , as the decimal separator if it is. In fact, I don't
believe it says anything at all, given that locale names of that form
were already allowed and are not now required. It basically amounts to a
suggestion that locale names be in that form.

Ben



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

Date: 04 Jan 2014 22:14:30 GMT
From: hymie@lactose.homelinux.net (hymie!)
Subject: sudden segmentation faults.  help?
Message-Id: <52c887c5$0$29765$862e30e2@ngroups.net>

So I'm not sure what I did, but the perl installation I've been using
is suddenly giving me segmentation faults when I try to load certain
modules.  Not all of them, just certain ones.

herman-pts/2:~% perl -v

This is perl 5, version 16, subversion 2 (v5.16.2) built for
i686-linux-thread-multi

herman-pts/1:~% perl
use Socket;
use Carp;
ues strict;
use App::Cpan;
zsh: segmentation fault  perl

herman-pts/2:~% perl -MCGI
zsh: segmentation fault  perl -MCGI

herman-pts/2:~% perl -MTime::Local
zsh: segmentation fault  perl -MTime::Local

herman-pts/2:~% perldoc
zsh: segmentation fault  perldoc

I don't know what I did, if I installed or uninstalled a corrupt
module, or a library changed and I don't know which one.  I'd be
happy to provide an strace , but I don't know what I'm looking
for.  I don't see anything obvious:

herman-pts/2:~% strace perldoc CGI
[...]
read(4, "groff\n    -l   Display the module"..., 8192) = 8192
brk(0x8275000)                          = 0x8275000
read(4, "lf->render_and_page(\\@found);\n}\n\n"..., 8192) = 8192
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++


herman-pts/2:~% strace cpan
[...]
read(7, "package Exporter;\n\nrequire 5.006;"..., 8192) = 8192
_llseek(7, 2366, [2366], SEEK_SET)      = 0
_llseek(7, 0, [2366], SEEK_CUR)         = 0
close(7)                                = 0
read(6, "/pwd', # OS/400 PASE.\n\t\t) {\n\n    "..., 8192) = 8192
brk(0x8233000)                          = 0x8233000
read(6, "-l $path) {\n\t    my $link_target "..., 8192) = 5378
--- SIGSEGV (Segmentation fault) @ 0 (0) ---
+++ killed by SIGSEGV +++

I'd really rather not download and install a whole new version of perl,
because then I'll probably have to redo mod_perl and all that other
stuff.  But perhaps I have no choice?

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net
-------------------------------------------------------------------------------


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

Date: Sat, 4 Jan 2014 23:41:01 +0000
From: Ben Morrow <ben@morrow.me.uk>
Subject: Re: sudden segmentation faults.  help?
Message-Id: <dpimpa-ghv.ln1@anubis.morrow.me.uk>


Quoth hymie@lactose.homelinux.net (hymie!):
> So I'm not sure what I did, but the perl installation I've been using
> is suddenly giving me segmentation faults when I try to load certain
> modules.  Not all of them, just certain ones.

Have you installed a new version of perl without rebuilding all the XS
modules?

[...]
> I don't know what I did, if I installed or uninstalled a corrupt
> module, or a library changed and I don't know which one.  I'd be
> happy to provide an strace , but I don't know what I'm looking
> for.  I don't see anything obvious:
> 
> herman-pts/2:~% strace perldoc CGI
> [...]
> read(4, "groff\n    -l   Display the module"..., 8192) = 8192
> brk(0x8275000)                          = 0x8275000
> read(4, "lf->render_and_page(\\@found);\n}\n\n"..., 8192) = 8192
> --- SIGSEGV (Segmentation fault) @ 0 (0) ---
> +++ killed by SIGSEGV +++

A C backtrace (assuming perl dumped core) is more likely to tell us
something useful than an strace. However, given that your perl is
unlikely to have debug symbols, it may still not say very much.

> I'd really rather not download and install a whole new version of perl,
> because then I'll probably have to redo mod_perl and all that other
> stuff.  But perhaps I have no choice?

Where did you get your perl from? Certainly the first step I would take
here would be to rebuild perl and all perl extensions, to see if that
made the problem go away; but if you didn't build your perl from source
that might just introduce additional confusion.

If you know how, it might be worth building a copy of perl of the same
version as the one you were using with a different installation prefix,
and installing some of the modules that fail into that perl. If the new
perl still fails then something's badly wrong somewhere. If you can
rebuild that perl (again) with -DDEBUGGING you are more likely to get a
useful backtrace.

Have you checked your hardware? Bad memory sometimes shows up like this.
If you can, try running memtest86.

Ben



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

Date: 05 Jan 2014 14:56:55 GMT
From: hymie@lactose.homelinux.net (hymie!)
Subject: Re: sudden segmentation faults.  help?
Message-Id: <52c972b7$0$29618$862e30e2@ngroups.net>

In our last episode, the evil Dr. Lacto had captured our hero,
  Ben Morrow <ben@morrow.me.uk>, who said:
>
>Have you checked your hardware? Bad memory sometimes shows up like this.
>If you can, try running memtest86.

I haven't run memtest86 yet, but I'm pretty sure I'm looking at a
hardware issue, and not a perl issue.

Thanks.

--hymie!    http://lactose.homelinux.net/~hymie    hymie@lactose.homelinux.net
-------------------------------------------------------------------------------


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

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:

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

Back issues are available via anonymous ftp from
ftp://cil-www.oce.orst.edu/pub/perl/old-digests. 

#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 4109
***************************************


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