[31202] in Perl-Users-Digest

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

Perl-Users Digest, Issue: 2447 Volume: 11

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Thu May 28 16:09:50 2009

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

Perl-Users Digest           Thu, 28 May 2009     Volume: 11 Number: 2447

Today's topics:
    Re: comma operator <frank@example.invalid>
    Re: comma operator <kst-u@mib.org>
    Re: comma operator <jameskuyper@verizon.net>
    Re: Is PERL good for a linguist new to programming? p.podmostko@googlemail.com
    Re: Is PERL good for a linguist new to programming? <1usa@llenroc.ude.invalid>
    Re: Is PERL good for a linguist new to programming? <uri@StemSystems.com>
    Re: Is PERL good for a linguist new to programming? p.podmostko@googlemail.com
    Re: Is PERL good for a linguist new to programming? <ghastings@gmail.com>
    Re: Is PERL good for a linguist new to programming? <frank@example.invalid>
    Re: Is PERL good for a linguist new to programming? <frank@example.invalid>
    Re: Is PERL good for a linguist new to programming? <uri@StemSystems.com>
        Perl and locales <jordi.kstells@gmail.com>
    Re: Perl and locales <smallpond@juno.com>
    Re: Perl and locales <1usa@llenroc.ude.invalid>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

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

Date: Thu, 28 May 2009 13:10:29 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: comma operator
Message-Id: <latp2bsaie9s.1e06uce6p0db2.dlg@40tude.net>

In Dread Ink, the Grave Hand of Keith Thompson Did Inscribe:

> Franken Sense <frank@example.invalid> writes:

> As for C's comma operator, I think it's already been explained.  The
> only really tricky thing about it is that the comma delimiter is used
> in a number of contexts where it's not an operator.  A rule of thumb
> that you might find useful is this: if the result of whatever appears
> to the left of a comma is not discarded, then it's not a comma
> operator.  For example, in a function call func(arg1, arg2), the value
> of arg1 is passed to the function, not discarded.

I see this as a contrast to perl.  All six args find their way to the
output:

C:\MinGW\source>perl gg1.pl
Mon => Monday
Sun => Sunday
Tue => Tuesday

C:\MinGW\source>type gg1.pl
#!/usr/bin/perl
# perl gg1.pl

use strict;
use warnings;


my %longday1 =
(
    ("Sun" , "Sunday"),
    ("Mon" ,"Monday"),
   ( "Tue" ,"Tuesday"),
);

foreach my $key (sort keys %longday1)
{
    print "$key => $longday1{$key}\n";
}

C:\MinGW\source>
-- 
Frank

It's the Power of the Almighty, the Splendor of Nature, and then you.
~~ Al Franken


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

Date: Thu, 28 May 2009 13:03:53 -0700
From: Keith Thompson <kst-u@mib.org>
Subject: Re: comma operator
Message-Id: <ln63flt2om.fsf@nuthaus.mib.org>

Franken Sense <frank@example.invalid> writes:
> In Dread Ink, the Grave Hand of Keith Thompson Did Inscribe:
>> Franken Sense <frank@example.invalid> writes:
>> As for C's comma operator, I think it's already been explained.  The
>> only really tricky thing about it is that the comma delimiter is used
>> in a number of contexts where it's not an operator.  A rule of thumb
>> that you might find useful is this: if the result of whatever appears
>> to the left of a comma is not discarded, then it's not a comma
>> operator.  For example, in a function call func(arg1, arg2), the value
>> of arg1 is passed to the function, not discarded.
>
> I see this as a contrast to perl.

The only real contrast is that Perl refers to a comma in list context
as a "comma operator", and C doesn't.  (C doesn't really have a "list
context", but it has things that are similar; initializers and
function-call argument lists are both things that Perl treats as "list
context".)  In both cases (Perl comma operator in list context, C
comma that's not an operator), it doesn't have the behavior of
discarding the left operand.

[...]
> #!/usr/bin/perl
> # perl gg1.pl
>
> use strict;
> use warnings;
>
>
> my %longday1 =
> (
>     ("Sun" , "Sunday"),
>     ("Mon" ,"Monday"),
>    ( "Tue" ,"Tuesday"),
> );
>
> foreach my $key (sort keys %longday1)
> {
>     print "$key => $longday1{$key}\n";
> }

Here's a somewhat similar C program, using an array rather than a
hash:

#include <stdio.h>

int main(void)
{
    char *longday1[] = {
        "Sun", "Sunday",
        "Mon", "Monday",
        "Tue", "Tuesday"
    };
    int i;

    for (i = 0; i < sizeof longday1 / sizeof longday1[0]; i ++) {
        puts(longday1[i]);
    }
    return 0;
}


The point here is that the commas in the initializer for longday1 are
not comma operators; they're merely part of the syntax of an
initializer.

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


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

Date: Thu, 28 May 2009 13:08:20 -0700 (PDT)
From: jameskuyper <jameskuyper@verizon.net>
Subject: Re: comma operator
Message-Id: <428d6c12-9af9-45df-8d13-7c823ee6abf9@s28g2000vbp.googlegroups.com>

Franken Sense wrote:
> In Dread Ink, the Grave Hand of Keith Thompson Did Inscribe:
>
> > Franken Sense <frank@example.invalid> writes:
>
> > As for C's comma operator, I think it's already been explained.  The
> > only really tricky thing about it is that the comma delimiter is used
> > in a number of contexts where it's not an operator.  A rule of thumb
> > that you might find useful is this: if the result of whatever appears
> > to the left of a comma is not discarded, then it's not a comma
> > operator.  For example, in a function call func(arg1, arg2), the value
> > of arg1 is passed to the function, not discarded.
>
> I see this as a contrast to perl.  All six args find their way to the
> output:
>
> C:\MinGW\source>perl gg1.pl
> Mon => Monday
> Sun => Sunday
> Tue => Tuesday
>
> C:\MinGW\source>type gg1.pl
> #!/usr/bin/perl
> # perl gg1.pl
>
> use strict;
> use warnings;
>
>
> my %longday1 =
> (
>     ("Sun" , "Sunday"),
>     ("Mon" ,"Monday"),
>    ( "Tue" ,"Tuesday"),
> );

in perl, whether ("Sun", "Sunday") is recognized as a list containing
two string elements separated by a comma or as a parenthesized comma
expression with a value of "Sunday" depends upon whether it occurs in
a list context or a scalar context. Since this is a list context, none
of those commas are comma operators. Try the following, where all of
the commas are comma operators:

     my $longday2 =
     (
        ("Sun" , "Sunday"),
        ("Mon" ,"Monday"),
        ("Tue" ,"Tuesday"),
    );

You will find that $longday2 has a value of "Tuesday".

The definition of %longday1 given above is syntactically comparable
(the semantics are quite different) to the C definition:

    char *longday3[][2] =
    {
        {"Sun" , "Sunday"},
        {"Mon" ,"Monday"},
        {"Tue" ,"Tuesday"},
    };

where the commas are also not comma operators. In C, the fact that
commas separating elements of an initializer list are not comma
operators is indicated by the fact that the grammar requires that
elements of initializer lists must be assignment-expressions. The
result of applying the comma operator is an expression, but it doesn't
qualify as an assignment-expression.

If you parenthesize an expression, it becomes a primary expression,
which does qualify as as an assignment expression. It would,
therefore, be perfectly possible to have comma operator in an
initializer, but only if it is parenthesized. Three of the six commas
in the following declaration are comma operators:

    char *longday4[] =
    {
        ("Sun" , "Sunday"),
        ("Mon" ,"Monday"),
        ("Tue" ,"Tuesday"),
    };


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

Date: Thu, 28 May 2009 01:05:53 -0700 (PDT)
From: p.podmostko@googlemail.com
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <99176fd6-5c93-4cca-85d8-fdede469f825@q14g2000vbn.googlegroups.com>

Well, thank you all for keeping faith in me :)

I'm a translator originally. The thing is that I have several ideas
regarding several small modules like dictionaries or thesauruses that
I would like to materialise. And yes, I do realise that it's a very
long way to start writing my own programs from scratch.

I have become inspired to get into computational linguistics after my
BA thesis where I tested various concordance-based tools and how they
cope with translating collocations.

But I also see learning Perl as a mental challenge for me. I have
always wanted to know a programming language and I always envied
people who had absolutely no problems with solving mathemathical
problems. Having said that, I'm not aspiring to be the next Dijkstra,
I just have some personal purposes for doing that. Nuff said.

Thank you once again for hospitality

Regards
Przemek


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

Date: Thu, 28 May 2009 13:42:11 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <Xns9C1962B55B8C4asu1cornelledu@127.0.0.1>

p.podmostko@googlemail.com wrote in
news:b00e5776-0ad2-4632-8c39-bb0878cd4afb@h11g2000yqb.googlegroups.com: 

> 
>> BTW, I think it's unrealistic that you would pick up programming
>> without a background in it.  My $.02 .
> 
> So you say that it's futile for me to continue studying it?

I had to look up his message in Google. Note that he did not say 
anything of substance except to complain about 'Uri and his ilk'.

Anyone with a capacity for logical thinking can program. It takes time 
and practice. It takes learning from mistakes.

The good thing about programming is the instant feedback loop. At the 
lowest level, perl will tell you if you have made a syntax error. 
However, it is possible have a program that perl will accept but does 
not do what you want. Then, you have to think harder about how to 
communicate what you want within the language. When you have a program 
that seems to do what you want, it is usually possible to improve on it 
by making it more succinct, by modifying the flow etc.

That is, programming is very close to writing.

When you eventually post programming questions here, your questions and 
proposed solutions will be critiqued. Expect that. You'd do well to take 
those critiques seriously (in terms of improving your skills).

Besides, did you notice the circular reasoning in "it's unrealistic that 
you would pick up programming without a background in it." How does one 
get a background in something without trying and doing first without a 
background?

Don't let this kind of silliness stop you from installing Perl and 
getting started (see http://www.ebb.org/PickingUpPerl/)

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

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


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

Date: Thu, 28 May 2009 10:41:28 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <871vq95lyf.fsf@quad.sysarch.com>

>>>>> "pp" == p podmostko <p.podmostko@googlemail.com> writes:

  pp> Well, thank you all for keeping faith in me :)
  pp> I'm a translator originally. The thing is that I have several ideas
  pp> regarding several small modules like dictionaries or thesauruses that
  pp> I would like to materialise. And yes, I do realise that it's a very
  pp> long way to start writing my own programs from scratch.

as i said, you have the correct attitude and goals. anyone with basic
logical skills and the interest can learn to program. the basics are
very easy. as i said the hard part is scaling your knowledge or the
problem space.

  pp> I have become inspired to get into computational linguistics after my
  pp> BA thesis where I tested various concordance-based tools and how they
  pp> cope with translating collocations.

those types of tools aren't hard programming problems IMO. and they are
very easily done in perl which is great for complex text analysis.

  pp> But I also see learning Perl as a mental challenge for me. I have
  pp> always wanted to know a programming language and I always envied
  pp> people who had absolutely no problems with solving mathemathical
  pp> problems. Having said that, I'm not aspiring to be the next Dijkstra,
  pp> I just have some personal purposes for doing that. Nuff said.

the fact you mentioned dijkstra (however you learned about him) is a
good sign!

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 28 May 2009 09:12:40 -0700 (PDT)
From: p.podmostko@googlemail.com
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <5b683b4b-ca09-4f30-a622-8d84693dfc64@q2g2000vbr.googlegroups.com>


Uri Guttman wrote:
> >>>>> "pp" == p podmostko <p.podmostko@googlemail.com> writes:
>
>   pp> Well, thank you all for keeping faith in me :)
>   pp> I'm a translator originally. The thing is that I have several ideas
>   pp> regarding several small modules like dictionaries or thesauruses that
>   pp> I would like to materialise. And yes, I do realise that it's a very
>   pp> long way to start writing my own programs from scratch.
>
> as i said, you have the correct attitude and goals. anyone with basic
> logical skills and the interest can learn to program. the basics are
> very easy. as i said the hard part is scaling your knowledge or the
> problem space.
>
>   pp> I have become inspired to get into computational linguistics after my
>   pp> BA thesis where I tested various concordance-based tools and how they
>   pp> cope with translating collocations.
>
> those types of tools aren't hard programming problems IMO. and they are
> very easily done in perl which is great for complex text analysis.
>
>   pp> But I also see learning Perl as a mental challenge for me. I have
>   pp> always wanted to know a programming language and I always envied
>   pp> people who had absolutely no problems with solving mathemathical
>   pp> problems. Having said that, I'm not aspiring to be the next Dijkstra,
>   pp> I just have some personal purposes for doing that. Nuff said.
>
> the fact you mentioned dijkstra (however you learned about him) is a
> good sign!
>
> uri
>
> --
> Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
> -----  Perl Code Review , Architecture, Development, Training, Support ------
> --------- Free Perl Training --- http://perlhunter.com/college.html ---------
> ---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------

Thank you for all good karma from you guys! I've actually started
O'Reilly's "Learning Perl" but I've found the "Elements of Perl
Programming" and Im going to start from that one instead if its said
to be so good for beginners.

Surprisingly, the MA translation courre in UCL in London has a module
on scripting and general programming and Im going to take it
(hopefully not for my own demise).

Wish me luck :P


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

Date: Thu, 28 May 2009 13:20:01 -0400
From: Gregg Hastings <ghastings@gmail.com>
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <0017c0f9$0$28926$c3e8da3@news.astraweb.com>

A. Sinan Unur wrote:
> The good thing about programming is the instant feedback loop. At the 
> lowest level, perl will tell you if you have made a syntax error. 
> However, it is possible have a program that perl will accept but does 
> not do what you want. Then, you have to think harder about how to 
> communicate what you want within the language. When you have a program 
> that seems to do what you want, it is usually possible to improve on it 
> by making it more succinct, by modifying the flow etc.
> 
> That is, programming is very close to writing.


Hi list.. First post.

The above seems to be my problem.. I have the desire to program.  I read
and play with examples.  I even understand the mechanics behind a lot of
it already.. (currently ch4 llama) .  My hurdle seems to be the
creativity and allowance perl allows.  I'm always looking for the 1+1=2
solution to the problem at hand and get buried there.. I suppose soon
enough and when I at least finish the book I might open up to the idea
of doing 'what works for me'.

To tryin' <ching>

Gregg


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

Date: Thu, 28 May 2009 12:14:59 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <1tptf6q6vloic$.173llzmasj1qf.dlg@40tude.net>

In Dread Ink, the Grave Hand of Uri Guttman Did Inscribe:

>>>>>> "FS" == Franken Sense <frank@example.invalid> writes:
> 
>   >> Sorry, but what does this have to do with anything? :) I don't
>   >> follow.
> 
>   FS> Uri and his ilk are why I would advise against thinking you can
>   FS> conquer the many idioms of perl by relying on usenet.  Post a few
>   FS> more questions as you supplement your study and watch their tone
>   FS> slip as you don't follow Uri's life advice.
> 
> the fact you aren't learning perl quickly yourself is no reason to rant
> about how usenet works or doesn't work. you have posted forever about a
> trivially simple problem and have taken forever to grasp the simplest
> perl idioms. you ignored coding and educational advice, you constantly
> seem to compare perl ops to similar ops in c and can't see the
> differences. your views on programming, and training aren't valid so why
> did you jump in here? i can't wait for keel to stick his nose in too.
> 
>   FS> clp.misc varies like any usenet group. Doesn't seem to be many
>   FS> OP's and Uri is front and center: hmmm.
> 
> huh?? try to make some sense.
> 
>   FS> Other times, it's been nice.  What's really helped me this time
>   FS> around is that I have a sysadmin buddy who looks at this stuff
>   FS> with me.  I don't regret the fifty dollars I laid out for
>   FS> _Programming Perl_.  YMMV.
> 
> so ask him to train you. 
> 
>   FS> BTW, I think it's unrealistic that you would pick up programming without a
>   FS> background in it.  My $.02 .
> 
> speak for yourself. you have some programming background and can't pick
> up basic perl that has been spoonfed to you. comment operator anyone?
> 
> uri

To OP: this is Uri in his usual tone.  If you can read this while supposing
yourself to be the second person without wanting to tell him to get bent,
then clp.misc is for u and uri is ur man.
-- 
Frank

Most of us here in the media are what I call infotainers...Rush Limbaugh is
what I call a disinfotainer. He entertains by spreading disinformation.
~~ Al Franken


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

Date: Thu, 28 May 2009 12:59:40 -0700
From: Franken Sense <frank@example.invalid>
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <1jkwjjdsg8jzm$.1da6vtd35ooeq.dlg@40tude.net>

In Dread Ink, the Grave Hand of p.podmostko@googlemail.com Did Inscribe:

>> BTW, I think it's unrealistic that you would pick up programming without a
>> background in it.  My $.02 .
> 
> So you say that it's futile for me to continue studying it?
> 
> Przemek

I'd liken it to an American learning Polish, which my friend Lynn did
without too much trouble.  (She studied linguistics at Wash U.)

She was the top student in French in high school, which gave her a
background for declination, case and pronunciation.  She's easily a one in
a hundred type person.

Perl, with its panoply of odd, unpronounceable symbols, is as
Polish-looking a syntax as I can think of.

That said, I would never tell you sight unseen that you aren't that
exceptional person.  I'm a huge advocate of continuing education, and
whatever floats your boat.  To quote James Brown:

"It's your thing; do what you wanna do."
-- 
Frank

       ......................  o    _______________           _,
      ` Good Morning!  ,      /\_  _|             |        .-'_|
      `................,     _\__`[_______________|       _| (_|
                             ] [ \, ][         ][        (_|


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

Date: Thu, 28 May 2009 15:23:41 -0400
From: "Uri Guttman" <uri@StemSystems.com>
Subject: Re: Is PERL good for a linguist new to programming?
Message-Id: <87fxep2fr6.fsf@quad.sysarch.com>

>>>>> "FS" == Franken Sense <frank@example.invalid> writes:

  FS> Perl, with its panoply of odd, unpronounceable symbols, is as
  FS> Polish-looking a syntax as I can think of.

please stop making comments on perl. you are not qualified to make
them. if you think perl is polish, then you haven't seen apl, lisp or
many other langs so stop making ignorant comments. yes, i said ignorant
since you don't know much computer science in general then you have no
basis from which you can make stupid comments.

just leave this thread and don't try to help anyone with perl for a good
long while.

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  --------  http://www.sysarch.com --
-----  Perl Code Review , Architecture, Development, Training, Support ------
--------- Free Perl Training --- http://perlhunter.com/college.html ---------
---------  Gourmet Hot Cocoa Mix  ----  http://bestfriendscocoa.com ---------


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

Date: Thu, 28 May 2009 18:59:42 +0200
From: kxtells <jordi.kstells@gmail.com>
Subject: Perl and locales
Message-Id: <LY-dnWfsEtVjX4PXnZ2dnUVZ8tednZ2d@giganews.com>

Hi everyone

I've got a little problem setting up perl locales to use for data 
formatting.

my default locale is -> en_US.UTF-8
but for a spanish output program i want to use -> es_ES.utf8

I'm on a ubuntu box, and this locales are configured:
  locale -a

ca_AD.utf8
ca_ES.utf8
ca_ES.utf8@valencia
ca_FR.utf8
ca_IT.utf8
en_US.utf8
es_ES.utf8


Then, in my perl program i use the following (I only show the important 
lines)

#including
use IO;
use Date::Parse;
use Date::Format;
use POSIX qw(locale_h);
use strict;
(...)
#first, set proper locales
my $old_locale = setlocale(LC_TIME);
print $old_locale."\n";

setlocale(LC_TIME, 'es_ES.utf8') or die "LOCALE TROUBLE!";
my $new_locale = setlocale(LC_TIME);
print $new_locale."\n";
(...)

sub format_date_norm(){
   my $date = @_[0];
   my $time;

   return time2str("%a %e", str2time($date));

}


When I call the function what I get is something like:
Mon May
but I needed
Lun May

The two print of the locales show the correct locale, the first print:
en_US.UTF-8

and the second print
es_ES.utf8


I've been looking but I can't find the sollution.

Does anyone has an idea of what's happening here?

Thanks a lot!

Kxtells


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

Date: Thu, 28 May 2009 14:59:34 -0400
From: Steve C <smallpond@juno.com>
Subject: Re: Perl and locales
Message-Id: <gvmmv4$hsf$1@news.eternal-september.org>

kxtells wrote:
> Hi everyone
> 
> I've got a little problem setting up perl locales to use for data 
> formatting.
> 
> my default locale is -> en_US.UTF-8
> but for a spanish output program i want to use -> es_ES.utf8
> 
> I'm on a ubuntu box, and this locales are configured:
>  locale -a
> 
> ca_AD.utf8
> ca_ES.utf8
> ca_ES.utf8@valencia
> ca_FR.utf8
> ca_IT.utf8
> en_US.utf8
> es_ES.utf8
> 
> 
> Then, in my perl program i use the following (I only show the important 
> lines)
> 
> #including
> use IO;
> use Date::Parse;
> use Date::Format;
> use POSIX qw(locale_h);
> use strict;
> (...)
> #first, set proper locales
> my $old_locale = setlocale(LC_TIME);
> print $old_locale."\n";
> 
> setlocale(LC_TIME, 'es_ES.utf8') or die "LOCALE TROUBLE!";
> my $new_locale = setlocale(LC_TIME);
> print $new_locale."\n";
> (...)
> 
> sub format_date_norm(){
>   my $date = @_[0];
>   my $time;
> 
>   return time2str("%a %e", str2time($date));
> 
> }
> 
> 
> When I call the function what I get is something like:
> Mon May
> but I needed
> Lun May
> 
> The two print of the locales show the correct locale, the first print:
> en_US.UTF-8
> 
> and the second print
> es_ES.utf8
> 
> 
> I've been looking but I can't find the sollution.
> 
> Does anyone has an idea of what's happening here?
> 
> Thanks a lot!
> 
> Kxtells


Weird.  Am I blind?  I don't see Spanish on the list.
http://search.cpan.org/~gbarr/TimeDate-1.16/

Anyway, the language modules are not big.  You can copy one and write your own.


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

Date: Thu, 28 May 2009 19:18:36 GMT
From: "A. Sinan Unur" <1usa@llenroc.ude.invalid>
Subject: Re: Perl and locales
Message-Id: <Xns9C199BBEF164Aasu1cornelledu@127.0.0.1>

kxtells <jordi.kstells@gmail.com> wrote in
news:LY-dnWfsEtVjX4PXnZ2dnUVZ8tednZ2d@giganews.com: 

> I've got a little problem setting up perl locales to use for data 
> formatting.
> 
> my default locale is -> en_US.UTF-8
> but for a spanish output program i want to use -> es_ES.utf8
> 
 ...

> Then, in my perl program i use the following (I only show the
> important lines)

But it is not a minimal example one can run by just copying and pasting.

> sub format_date_norm(){
>    my $date = @_[0];
>    my $time;
> 
>    return time2str("%a %e", str2time($date));
> }

You don't show how you call this function, but the empty prototype and 
the incorrect @_[0] (should be $_[0]) are annoying and makes me 
suspicious of what else might be happening in the parts you do not show.

In any case, the following works for me on ArchLinux using the 
distribution's Perl 5.10. Does it work in your case?

#!/usr/bin/perl

use strict;
use warnings;

use POSIX qw(strftime locale_h);

my $old_locale = setlocale(LC_TIME);
print $old_locale."\n";

setlocale(LC_TIME, 'tr_TR.utf8') or die "LOCALE TROUBLE!";
my $new_locale = setlocale(LC_TIME);
print $new_locale."\n";

print strftime( "%A, %B %d, %Y\n", localtime );

__END__

[sinan@kas ~]$ t.pl
en_US.utf8
tr_TR.utf8
Persembe, Mayis 28, 2009

(I got rid of the accented Turkish characters for pasting). This example 
also points out a little problem. The preferred way to display this date 
in Turkish would have been

28 Mayis 2009, Persembe

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

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


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

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

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

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

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V11 Issue 2447
***************************************


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