[29208] in Perl-Users-Digest
Perl-Users Digest, Issue: 452 Volume: 11
daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Tue May 22 14:10:22 2007
Date: Tue, 22 May 2007 11:09:07 -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 Tue, 22 May 2007 Volume: 11 Number: 452
Today's topics:
Re: Catching SIGALRM in a thread <zentara@highstream.net>
Re: Catching SIGALRM in a thread xhoster@gmail.com
converting code via regex <jpreston@general-steel.com>
Re: converting code via regex <zen13097@zen.co.uk>
Re: converting code via regex <jpreston@general-steel.com>
Re: executing an sql statement in perl xhoster@gmail.com
Re: ExtUtils::MakeMaker - how to distribute CGI script? <bwooster47@gmail.com>
Re: localtime(time()) <t-use@gmx.net>
Re: localtime(time()) <mgjv@tradingpost.com.au>
Re: localtime(time()) <tony_curtis32@yahoo.com>
Re: localtime(time()) <t-use@gmx.net>
Re: localtime(time()) <t-use@gmx.net>
Re: localtime(time()) <uri@stemsystems.com>
Re: localtime(time()) <sisyphus1@nomail.afraid.org>
math::gmp install problem <jrpfinch@gmail.com>
Re: math::gmp install problem <sisyphus1@nomail.afraid.org>
Re: Perl and German Umlauts <idontlikespam@denniswinter.de>
Re: Perl and German Umlauts <idontlikespam@denniswinter.de>
Re: Perl and German Umlauts <ben.usenet@bsb.me.uk>
Re: Unicode in regexp <nobull67@gmail.com>
Re: Unicode in regexp <nobull67@gmail.com>
Re: Unicode in regexp <nobull67@gmail.com>
Re: Unicode in regexp <nobull67@gmail.com>
Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)
----------------------------------------------------------------------
Date: Tue, 22 May 2007 15:21:26 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Catching SIGALRM in a thread
Message-Id: <9526535ij0vjng77h817t37rvhsbf2fom4@4ax.com>
On Mon, 21 May 2007 20:00:05 +0000 (UTC), Samuel <newsgroups@debain.org>
wrote:
>On Mon, 21 May 2007 15:16:48 +0000, xhoster wrote:
>
>> I don't. I use forking instead of threads, almost always. And when I
>> can't, I strongly consider using a different language.
>
>By now, that's pretty much my conclusion. The fact that sharing nested
>objects between threads is only possible by making every object and all
>of it's attributes thread aware makes things *really* cumbersome. I am
>currently looking into the alternatives.
>
>> My Net::Telnet documentation doesn't mention thread safety. I'd take
>> that as a caution against using Net::Telnet with threads.
>
>Yay, another problem! Things could have been going a little bit
>smoother... well, at least I have a working prototype.
>
>Thank you for your comment!
>
>-Samuel
Here is an example I have of an ALARM in a thread. It works for me,
but it may not be what you are looking for. (Honestly I didn't read
this question slowly :-) )
My notes indicates threads
and alarms don't work reliably together, but this seems to do OK.
#!/usr/bin/perl
use warnings;
use strict;
use threads;
use threads::shared;
my $waitTime : shared;
my $done : shared;
my $return : shared;
$waitTime = 5;
$done = 0;
$return = '';
my $cmd = './z1';
my $thr = threads->new(\&my_exec_thread, $cmd);
while(1){
if ( $done == 1 ) {
print "Thread completed \n";
print "return= $return\n";
$thr->join;
last;
}elsif ( $done eq 'TIMED OUT' ) {
print "Thread Timed OUT\n";
$thr->join;
last;
}else{next}
}
print "1\n";
######################################################
sub my_exec_thread {
my $cmd = shift;
print ("In thread ".$cmd."\n");
my $maxTime = 5;
my $child_pid;
local $SIG{ALRM} = sub { die "timeout" };
eval {
alarm($maxTime);
unless ($child_pid = fork) {
exec $cmd;
die "could not exec $cmd: $!";
}
wait;
alarm(0);
};
if ($@) {
print $@,"\n";
if ($@ =~ /timeout/) {
local $SIG{'HUP'} = 'IGNORE';
kill('HUP', $child_pid);
return;
}
}
print "end of thread code block\n";
}
__END__
##########################################################
My $cmd ./z1 is simply:
#!/usr/bin/perl
use warnings;
use strict;
my $count = 0;
while(1){
$count++;
print "$count\n";
sleep 1;
}
__END__
zentara
--
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html
------------------------------
Date: 22 May 2007 15:44:28 GMT
From: xhoster@gmail.com
Subject: Re: Catching SIGALRM in a thread
Message-Id: <20070522114430.046$qQ@newsreader.com>
zentara <zentara@highstream.net> wrote:
> On Mon, 21 May 2007 20:00:05 +0000 (UTC), Samuel <newsgroups@debain.org>
> wrote:
>
> >On Mon, 21 May 2007 15:16:48 +0000, xhoster wrote:
> >
> >> I don't. I use forking instead of threads, almost always. And when I
> >> can't, I strongly consider using a different language.
> >
> >By now, that's pretty much my conclusion. The fact that sharing nested
> >objects between threads is only possible by making every object and all
> >of it's attributes thread aware makes things *really* cumbersome. I am
> >currently looking into the alternatives.
> >
> >> My Net::Telnet documentation doesn't mention thread safety. I'd take
> >> that as a caution against using Net::Telnet with threads.
> >
> >Yay, another problem! Things could have been going a little bit
> >smoother... well, at least I have a working prototype.
> >
> >Thank you for your comment!
> >
> >-Samuel
>
> Here is an example I have of an ALARM in a thread. It works for me,
> but it may not be what you are looking for.
What OS and what version of Perl are you using?
Your code doesn't work for me. The main program is blown away by
the alarm, without catching it in the SIG{ALRM} and without
clobbering the z1 process, which just keeps on running.
This is perl, v5.8.3 built for x86_64-linux-thread-multi
Thanks,
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: Tue, 22 May 2007 08:21:23 -0500
From: "Jerry" <jpreston@general-steel.com>
Subject: converting code via regex
Message-Id: <1355rhbmfns22bd@corp.supernews.com>
HI!
I am converting some old code:
$_ = " if (a.weight = '') and (a.w <> 'N') then"
to the following
$_ = "if ( a.weight[ a.L_NO_ ].ToString() == 0 ) and ( a.w <> 'N' ) then
using
s/(\w)\.\b$WordList{ $Word }\b/$1\.$WordList{ $Word }\[ $1.L_NO_
\].ToString\(\)/g;
Why does this not change the"a.w". I have a hash of key words that I am
looping through
I am looking for a finished product of
_$ = "if( ( a.weight[ a.L_NO_ ].ToString() == 0 ) && ( a.w[
a.L_NO_ ].ToString() != 'N' ) )"
Thanks,
Jerry
------------------------------
Date: 22 May 2007 14:44:29 GMT
From: Dave Weaver <zen13097@zen.co.uk>
Subject: Re: converting code via regex
Message-Id: <465301cd$0$31824$db0fefd9@news.zen.co.uk>
On Tue, 22 May 2007 08:21:23 -0500, Jerry <jpreston@general-steel.com> wrote:
> I am converting some old code:
>
> $_ = " if (a.weight = '') and (a.w <> 'N') then"
>
> to the following
>
> $_ = "if ( a.weight[ a.L_NO_ ].ToString() == 0 ) and ( a.w <> 'N' ) then
^^^^^
How did '' become 0 ?
> using
>
> s/(\w)\.\b$WordList{ $Word }\b/$1\.$WordList{ $Word }\[ $1.L_NO_
> \].ToString\(\)/g;
No need to escape most of that in the replacement part, because those
characters are only special in a regular expression (the left-hand
part of the s/// operator), not a plain string (the right-hand part).
Although I had to leave in the escaped [ otherwise perl assumes it's
part of the $WordList{} expression and tries to interpolate it.
> Why does this not change the"a.w". I have a hash of key words that I am
> looping through
It works for me. If you'd shown a *short* but *complete* program that
illustrates your problem (as the posting guidelines for this group
suggest) we could have shown you what you did wrong.
#!/usr/bin/perl
use strict;
use warnings;
$_ = " if ( a.weight == 0 ) and ( a.w <> 'N' ) then";
my %WordList = ( foo => 'weight', bar => 'w' );
for my $Word ( qw(foo bar) ) {
s{(\w)\.\b$WordList{ $Word }\b}
{$1.$WordList{ $Word }\[ $1.L_NO_ ].ToString()}g;
}
print "$_\n";
Produces:
if ( a.weight[ a.L_NO_ ].ToString() == 0 ) and
( a.w[ a.L_NO_ ].ToString() <> 'N' ) then
Apart from the removal of the unneccessary back-whacks and the use of
{} as the delimiter (for better wrapping in this post), the s///
remains the same as your example.
> I am looking for a finished product of
>
> _$ = "if( ( a.weight[ a.L_NO_ ].ToString() == 0 ) && ( a.w[
> a.L_NO_ ].ToString() != 'N' ) )"
What happened to the " then" at the end?
------------------------------
Date: Tue, 22 May 2007 09:55:24 -0500
From: "Jerry" <jpreston@general-steel.com>
Subject: Re: converting code via regex
Message-Id: <135611lbqt45g7c@corp.supernews.com>
ok!
s/then//;
my $wordCNT = 0;
my ( @Word ) = /\.(\w+)/g;
foreach my $Word ( @Word) {
my %WordList = ( "footage" => "footage",
"qty" => "qty",
"total" => "total",
"totalcost" => "totalcost",
"count" => "count",
"weight" => "weight",
"estcost" => "estcost",
"cost" => "cost",
"totwgt" => "totwgt",
"wt_SLASH_ft" => "wt_SLASH_ft",
"tothigh" => "tothigh",
"wt_SLASH_each" => "wt_SLASH_each",
"wt_SLASH_sht" => "wt_SLASH_sht",
"c" => "c",
"w" => "w",
"dimension" => "dimension",
"freight" => "freight",
"onhand" => "onhand",
"ft_oh" => "ft_oh",
"vendor" => "vendor",
"ordered" => "ordered",
"recd" => "recd",
"ln_NO_" => "ln_NO_",
"item_NO_" => "item_NO_",
"amount" => "amount",
"price" => "price",
"wgt_ea" => "wgt_ea",
"priceea" => "priceea",
"unit" => "unit",
"um" => "um",
"u_SLASH_m" => "u_SLASH_m",
"dl_NO_" => "dl_NO_",
"pt_NO_" => "pt_NO_",
"d" => "d",
"p" => "p",
"sku_NO_" => "sku_NO_",
"invitem_NO_" => "invitem_NO_",
"i" => "i",
"pt_NO_" => "pt_NO_",
"sell" => "sell",
"invqty" => "invqty",
"description" => "description",
"t" => "t",
"qtyout" => "qtyout",
"qtyout" => "qtyout",
"wgtout" => "wgtout",
"pc" => "pc",
"uofm" => "uofm",
"baldue" => "baldue",
"ptyp" => "ptyp",
"po_NO_" => "po_NO_",
"ap_NO_" => "ap_NO_",
"fob" => "fob",
"product" => "product",
"onorder" => "onorder",
"qtyin" => "qtyin",
"wgtin" => "wgtin",
"invdate" => "invdate",
"sr" => "sr",
"city" => "city",
"name" => "name",
"pt" => "pt",
);
if( $WordList{ $Word } )
{
#print "$File, $Word*$#WordList*$WordList{ $Word }\n";
#print $_ if /\"N\" \) \)/i;
s/(\w)\.\b$WordList{ $Word }\b \);/$1\.$WordList{ $Word }\[
$1.L_NO_ \] \n/g if /get/;
s/(\w)\.\b$WordList{ $Word }\b/$1\.$WordList{ $Word }\[ $1.L_NO_
\]/g if /^\s+(\w)\./ && $wordCNT == 0 && !/$WordList{ $Word }\[/i;
s/(\w)\.\b$WordList{ $Word }\b/$1\.$WordList{ $Word }\[ $1.L_NO_
\].ToString\(\)/g if /sorts/ && $wordCNT > 0;
s/(\w)\.\b$WordList{ $Word }\b/$1\.$WordList{ $Word }\[ $1.L_NO_
\].ToString\(\)/g if( /= \"/ || /!= \"/ || /== \"/ ) && !/\[/ && !/\*
\w\./g;
s/(\w)\.\b$WordList{ $Word }\b /$1\.$WordList{ $Word }\[
$1.L_NO_ \].ToString\(\) /g if( /!= \"n\"/i && $wordCNT > 0 );
#print $_ if /\"N\" \) \)/i;
s/(\w)\.\b$WordList{
$Word }\b\s+==\s+\"(\w+)\"/utils\.IsMatch\( $1\.$WordList{ $Word }\[
$1.L_NO_ \].ToString\(\), \"$2\" \)/g if !/\.ToString/ && !/\* \w\./g;
s/(\w)\.\b$WordList{
$Word }\b\s+\!=\s+\"(\w+)\"/utils\.NotMatch\( $1\.$WordList{ $Word }\[
$1.L_NO_ \].ToString\(\), \"$2\" \)/g if !/\.ToString/ && !/\* \w\./g;
# s/(\w)\.\b$WordList{ $Word }\b\s+\)/$1\.$WordList{ $Word }\[
$1.L_NO_ \].ToString\(\) \)/g if !/\),/;
s/(\w)\.\b$WordList{ $Word }\b\.ToString/$1\.$WordList{
$Word }\[ $1.L_NO_ \]\.ToString/g;
s/(\w)\.\b$WordList{ $Word }\b\s+= /$1\.$WordList{ $Word }\[
$1.L_NO_ \] = /g;
s/(\w)\.\b$WordList{ $Word }\b\s+\)/$1\.$WordList{ $Word }\[
$1.L_NO_ \] \)/g if !/\),/ && $wordCNT == 0;
s/(\w)\.\b$WordList{ $Word }\b/float.Parse\( $1\.$WordList{
$Word }\[ $1.L_NO_ \].ToString\(\) \)/g if !/(\w)\.$WordList{ $Word }\[/;
# s/(\w)\.$WordList{ $Word };/float.Parse\( $1\.$WordList{
$Word }\[ $1.L_NO_ \].ToString\(\) \);/g;
# s/(\w)\.$WordList{ $Word } /float.Parse\( $1\.$WordList{
$Word }\[ $1.L_NO_ \].ToString\(\) \) /g;
# s/(\w)\.$WordList{ $Word }$/float.Parse\( $1\.$WordList{
$Word }\[ $1.L_NO_ \].ToString\(\) \);/g;
$wordCNT++;
}
}
"Dave Weaver" <zen13097@zen.co.uk> wrote in message
news:465301cd$0$31824$db0fefd9@news.zen.co.uk...
> On Tue, 22 May 2007 08:21:23 -0500, Jerry <jpreston@general-steel.com>
> wrote:
>> I am converting some old code:
>>
>> $_ = " if (a.weight = '') and (a.w <> 'N') then"
>>
>> to the following
>>
>> $_ = "if ( a.weight[ a.L_NO_ ].ToString() == 0 ) and ( a.w <> 'N' )
>> then
> ^^^^^
> How did '' become 0 ?
>
>> using
>>
>> s/(\w)\.\b$WordList{ $Word }\b/$1\.$WordList{ $Word }\[ $1.L_NO_
>> \].ToString\(\)/g;
>
> No need to escape most of that in the replacement part, because those
> characters are only special in a regular expression (the left-hand
> part of the s/// operator), not a plain string (the right-hand part).
> Although I had to leave in the escaped [ otherwise perl assumes it's
> part of the $WordList{} expression and tries to interpolate it.
>
>> Why does this not change the"a.w". I have a hash of key words that I
>> am
>> looping through
>
> It works for me. If you'd shown a *short* but *complete* program that
> illustrates your problem (as the posting guidelines for this group
> suggest) we could have shown you what you did wrong.
>
> #!/usr/bin/perl
> use strict;
> use warnings;
>
> $_ = " if ( a.weight == 0 ) and ( a.w <> 'N' ) then";
>
> my %WordList = ( foo => 'weight', bar => 'w' );
>
> for my $Word ( qw(foo bar) ) {
> s{(\w)\.\b$WordList{ $Word }\b}
> {$1.$WordList{ $Word }\[ $1.L_NO_ ].ToString()}g;
> }
>
> print "$_\n";
>
> Produces:
>
> if ( a.weight[ a.L_NO_ ].ToString() == 0 ) and
> ( a.w[ a.L_NO_ ].ToString() <> 'N' ) then
>
> Apart from the removal of the unneccessary back-whacks and the use of
> {} as the delimiter (for better wrapping in this post), the s///
> remains the same as your example.
>
>> I am looking for a finished product of
>>
>> _$ = "if( ( a.weight[ a.L_NO_ ].ToString() == 0 ) && ( a.w[
>> a.L_NO_ ].ToString() != 'N' ) )"
>
> What happened to the " then" at the end?
>
------------------------------
Date: 22 May 2007 14:46:06 GMT
From: xhoster@gmail.com
Subject: Re: executing an sql statement in perl
Message-Id: <20070522104607.789$kM@newsreader.com>
Dennis Roesler <noone@nowhere.com> wrote:
>
> I don't think place holders will work with $dbh->do because that does a
> prepare and execute in one go.
>
> http://search.cpan.org/~timb/DBI-1.56/DBI.pm#do
Look at the third line of the initial examples in the link you just posted:
$rows = $dbh->do($statement, \%attr, @bind_values) or die ...
(As a hint, if you have no \%attr to pass, just use undef instead.)
Xho
--
-------------------- http://NewsReader.Com/ --------------------
Usenet Newsgroup Service $9.95/Month 30GB
------------------------------
Date: 22 May 2007 10:30:42 -0700
From: "bwooster47@gmail.com" <bwooster47@gmail.com>
Subject: Re: ExtUtils::MakeMaker - how to distribute CGI script?
Message-Id: <1179855042.441126.302520@q75g2000hsh.googlegroups.com>
On May 21, 1:27 pm, brian d foy <brian.d....@gmail.com> wrote:
> In article <1179677304.637267.57...@e65g2000hsc.googlegroups.com>,
>
> <"bwooste...@gmail.com"> wrote:
> > Is there any documentation on how to distribute CGI scripts using the
> > ExtUtils::MakeMaker mechanisms?
>
> > It has EXE_FILES which are copied to the INSTALLSCRIPT location, is
> > there something similar for CGI scripts? CGI scripts need modification...
> However, have you considered taking everything that you'd need to
> configure and moving it outside the script?
Let's say that is done - how does one distribute a .cgi file, that
needs to go into something like /var/www/html/cgi-bin, in a Perl
Module package?
There is the current concept of putting scripts into the bin/ folder,
and modules in lib/ directories. Not sure if there is a similar
mechanism for CGI scripts.
------------------------------
Date: 22 May 2007 13:09:19 GMT
From: Martin Trautmann <t-use@gmx.net>
Subject: Re: localtime(time())
Message-Id: <slrnf55qrv.sqm.t-use@ID-685.user.individual.de>
On Tue, 22 May 2007 14:55:27 +0200, Gunnar Hjalmarsson wrote:
> Martin Trautmann wrote:
> > what's wrong about my interpretation of localtime?
>
> Interpretation? You didn't read the docs.
>
> perldoc -f localtime
Thanks, you're right - I checked cpan.org, but failed to check perldoc
first.
------------------------------
Date: Tue, 22 May 2007 23:11:14 +1000
From: Martien verbruggen <mgjv@tradingpost.com.au>
Subject: Re: localtime(time())
Message-Id: <slrnf55qvi.fcb.mgjv@martien.heliotrope.home>
On 22 May 2007 12:16:09 GMT,
Martin Trautmann <t-use@gmx.net> wrote:
>
> Hi all,
>
> what's wrong about my interpretation of localtime?
>
> perl -e '($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time());
> my $date =($year+1900)."-".
> sprintf("%02d", $mon) ."-".
> sprintf("%02d", $mday);
> print $date;'
>
> ... returns 2007-04-22 instead of 2007-05-22.
>
> Do I need to increment the month count since Janury is counted as zero?
The documentation for localtime states:
$ perldoc -f localtime
[SNIP]
$mday is the day of the
month, and $mon is the month itself, in the range 0..11 with 0
indicating January and 11 indicating December.
[SNIP]
I believe the answer to your question is in that bit.
Did you know about perldoc? If not, perldoc -f reads the perlfunc
documentation, and displays that part of that documentation file that
pertains to the function you give it as an argument. You can, of course,
simply read perlfuncdirectly. It's a lot faster than posting to Usenet.
It's interesting that the variable list you use is identical to that
from the documentation.
Martien
--
|
Martien Verbruggen | If it isn't broken, it doesn't have enough
| features yet.
|
------------------------------
Date: Tue, 22 May 2007 09:31:57 -0400
From: Tony Curtis <tony_curtis32@yahoo.com>
Subject: Re: localtime(time())
Message-Id: <f2urcb$f7a$1@knot.queensu.ca>
Martin Trautmann wrote:
> Hi all,
>
> what's wrong about my interpretation of localtime?
>
> perl -e '($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time());
> my $date =($year+1900)."-".
> sprintf("%02d", $mon) ."-".
> sprintf("%02d", $mday);
> print $date;'
>
> ... returns 2007-04-22 instead of 2007-05-22.
>
> Do I need to increment the month count since Janury is counted as zero?
Well, you've answered your own question...but simpler is:
use POSIX qw( strftime );
print strftime '%Y-%m-%d', localtime();
hth
t
------------------------------
Date: 22 May 2007 14:14:25 GMT
From: Martin Trautmann <t-use@gmx.net>
Subject: Re: localtime(time())
Message-Id: <slrnf55um1.sqm.t-use@ID-685.user.individual.de>
On Tue, 22 May 2007 23:11:14 +1000, Martien verbruggen wrote:
> Did you know about perldoc? If not, perldoc -f reads the perlfunc
> documentation, and displays that part of that documentation file that
> pertains to the function you give it as an argument. You can, of course,
> simply read perlfuncdirectly. It's a lot faster than posting to Usenet.
I ftp'ed the file to a cgi place where I found the bug later on - thus I
did not have access to perldoc.
> It's interesting that the variable list you use is identical to that
> from the documentation.
It was taken from the documentation before...
... where I just had expected a different meaning. $years was ok
(counting from 1900), while I was surprised by $mon, which was $mon--
instead - good for array processing, but not what it looked like.
Yes, shame on me for not reading the docu...
Fortunately, I got extra feedback, showing the even better solution,
Thanks,
Martin
------------------------------
Date: 22 May 2007 14:14:53 GMT
From: Martin Trautmann <t-use@gmx.net>
Subject: Re: localtime(time())
Message-Id: <slrnf55umt.sqm.t-use@ID-685.user.individual.de>
On Tue, 22 May 2007 09:31:57 -0400, Tony Curtis wrote:
> Well, you've answered your own question...but simpler is:
>
> use POSIX qw( strftime );
>
> print strftime '%Y-%m-%d', localtime();
Thanks!
Martin
------------------------------
Date: Tue, 22 May 2007 14:29:57 GMT
From: Uri Guttman <uri@stemsystems.com>
Subject: Re: localtime(time())
Message-Id: <x78xbhexsr.fsf@mail.sysarch.com>
>>>>> "MT" == Martin Trautmann <t-use@gmx.net> writes:
MT> I ftp'ed the file to a cgi place where I found the bug later on - thus I
MT> did not have access to perldoc.
ever heard of perldoc.perl.org? or installing perl on your desktop so
you can have perldoc locally? the excuse "i didn't have access to
perldoc" is weaker than your dog eating your computer.
uri
--
Uri Guttman ------ uri@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org
------------------------------
Date: Wed, 23 May 2007 02:40:29 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: localtime(time())
Message-Id: <46531cdc$0$17388$afc38c87@news.optusnet.com.au>
"Uri Guttman" <uri@stemsystems.com> wrote in message
news:x78xbhexsr.fsf@mail.sysarch.com...
.
.
> the excuse "i didn't have access to
> perldoc" is weaker than your dog eating your computer.
Hah !!
(I always blame someone else's dog :-)
Cheers,
Rob
------------------------------
Date: 22 May 2007 08:56:58 -0700
From: jrpfinch <jrpfinch@gmail.com>
Subject: math::gmp install problem
Message-Id: <1179849418.090618.154300@q75g2000hsh.googlegroups.com>
I'm trying to install the Math::GMP module on Sparc Solaris 8 and
receive the following error:
bash-2.03# make
/opt/SUNWspro/bin/cc -c -I/usr/local/include -D_LARGEFILE_SOURCE -
D_FILE_OFFSET_BITS=64 -O -DVERSION=\"2.04\" -DXS_VERSION=\"2.04\" -
KPIC "-I/usr/local/lib/perl5/5.8.8/sun4-solaris/CORE" GMP.c
Running Mkbootstrap for Math::GMP ()
chmod 644 GMP.bs
rm -f blib/arch/auto/Math/GMP/GMP.so
LD_RUN_PATH="/usr/local/lib" /opt/SUNWspro/bin/cc -G -L/usr/lib -L/
usr/ccs/lib -L/opt/SUNWspro/WS6U2/lib -L/usr/local/lib GMP.o -o blib/
arch/auto/Math/GMP/GMP.so \
-lgmp \
ld: fatal: file /usr/local/lib/libgmp.so: wrong ELF class: ELFCLASS64
ld: fatal: File processing errors. No output written to blib/arch/auto/
Math/GMP/GMP.so
*** Error code 1
make: Fatal error: Command failed for target `blib/arch/auto/Math/GMP/
GMP.so'
This is when I have installed GMP (successfully) using ./configure CC=/
opt/SUNWspro/bin/cc.
If I try to make GMP after using ./configure CC=/opt/SUNWspro/bin/cc
ABI=32 (doing a make clean first) I get:
bash-2.03# make
make all-recursive
Making all in tests
Making all in .
Making all in devel
Making all in mpn
Making all in mpz
Making all in mpq
Making all in mpf
Making all in rand
Making all in misc
Making all in cxx
Making all in mpbsd
Making all in mpn
/bin/bash ../libtool --mode=compile /opt/SUNWspro/bin/cc -
DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -I.. -
DOPERATION_`echo fib_table | sed 's/_$//'` -xO4 -xarch=v8plus -
xchip=ultra3 -c -o fib_table.lo fib_table.c
mkdir .libs
/opt/SUNWspro/bin/cc -DHAVE_CONFIG_H -I. -I. -I.. -D__GMP_WITHIN_GMP -
I.. -DOPERATION_fib_table -xO4 -xarch=v8plus -xchip=ultra3 -c
fib_table.c -KPIC -DPIC -o .libs/fib_table.o
"../fib_table.h", line 4: warning: old-style declaration or incorrect
type for: Error
"../fib_table.h", line 4: warning: old-style declaration or incorrect
type for: error
"../fib_table.h", line 4: warning: old-style declaration or incorrect
type for: this
"../fib_table.h", line 4: syntax error before or at: data
"../fib_table.h", line 4: warning: old-style declaration or incorrect
type for: data
"../fib_table.h", line 4: warning: old-style declaration or incorrect
type for: is
"../mp_bases.h", line 4: warning: old-style declaration or incorrect
type for: bits
"../mp_bases.h", line 4: warning: old-style declaration or incorrect
type for: Error
"../mp_bases.h", line 4: warning: old-style declaration or incorrect
type for: error
"../mp_bases.h", line 4: warning: old-style declaration or incorrect
type for: this
"../mp_bases.h", line 4: syntax error before or at: data
"../mp_bases.h", line 4: warning: old-style declaration or incorrect
type for: data
"../mp_bases.h", line 4: warning: old-style declaration or incorrect
type for: is
"/usr/include/sys/int_types.h", line 62: warning: old-style
declaration or incorrect type for: bits
"fib_table.c", line 7: warning: old-style declaration or incorrect
type for: Error
"fib_table.c", line 7: warning: old-style declaration or incorrect
type for: error
"fib_table.c", line 7: warning: old-style declaration or incorrect
type for: this
"fib_table.c", line 7: syntax error before or at: data
"fib_table.c", line 7: warning: old-style declaration or incorrect
type for: data
"fib_table.c", line 7: warning: old-style declaration or incorrect
type for: is
"fib_table.c", line 10: warning: old-style declaration or incorrect
type for: bits
cc: acomp failed for fib_table.c
*** Error code 1
make: Fatal error: Command failed for target `fib_table.lo'
Current working directory /tmp/gmp-4.2.1/mpn
*** Error code 1
make: Fatal error: Command failed for target `all-recursive'
Current working directory /tmp/gmp-4.2.1
*** Error code 1
make: Fatal error: Command failed for target `all'
I would be very grateful for any advice - I have spent all day trying
to get this to work and am tearing my hair out.
Many thanks
Jon
------------------------------
Date: Wed, 23 May 2007 03:01:58 +1000
From: "Sisyphus" <sisyphus1@nomail.afraid.org>
Subject: Re: math::gmp install problem
Message-Id: <465321e5$0$24411$afc38c87@news.optusnet.com.au>
"jrpfinch" <jrpfinch@gmail.com> wrote in message
.
.
>
> This is when I have installed GMP (successfully) using ./configure CC=/
> opt/SUNWspro/bin/cc.
>
I really don't know if it will help (or even if you want to go down this
path) but, if you're having trouble building Math::GMP against a dynamic
build of gmp, you could try building Math::GMP against a *static* build of
gmp:
./configure CC=/opt/SUNWspro/bin/cc --disable-shared --enable-static
I guess the other consideration is that you *should* be able to build
against a shared lib if you want to ... but a static lib could be worth a
try if you have no particular reason to persist with a shared lib.
Cheers,
Rob
------------------------------
Date: Tue, 22 May 2007 15:57:27 +0200
From: Dennis Winter <idontlikespam@denniswinter.de>
Subject: Re: Perl and German Umlauts
Message-Id: <f2ust8$ndq$2@murphy.mediascape.de>
Hi Ben,
Ben Bacarisse schrieb:
>> [...]
>
> It is usually unhelpful to post such output because too many
> components might have messed with it. I'd post a hex dump[1]. For
> example on my system you program's output is:
>
> 00000000 41 c3 84 c3 a4 20 4f c3 96 c3 b6 20 55 c3 9c c3 |A.... O.... U...|
> 00000010 bc 20 73 73 c3 9f |. ss..|
> 00000016
>
> Form this is can see that, as expected, the string is printed
> literally. Your accented characters are UTF-8 encoded in the source,
> and that is how they come out. In fact, because I have my terminal
> character encoding set to UTF-8, you program prints: AÄä OÖö UÜü ssß
> if I view the output directly.
Okay, thanks for that note...
>> [...]
>> The OS is running as a German environment. How can I tell Perl to use
>> the german charset?
>
> OK, but how do you want these characters to be encoded, both in the
> source and in the output? You seem to have chosen UTF-8 for the
> source and if you want the same for the output you will need to have a
> device that is expecting to see that encoding.
I´m creating textfiles from a PHP-frontend, each containing an absolute
path to a file on the filesystem. Normally PHP saves the file in
ASCII-mode, but if there are umlauts in name of the file, PHP saves the
textfile als UTF-8. Then, when I try to read the created textfiles using
perl, the umlauts are mutilated. Watching the textfile I can see that
the path itself has been saved correctly. But Perl seems to read the
file with a different charset.
Thanks you!
Dennis
------------------------------
Date: Tue, 22 May 2007 16:01:42 +0200
From: Dennis Winter <idontlikespam@denniswinter.de>
Subject: Re: Perl and German Umlauts
Message-Id: <f2ut57$ndq$4@murphy.mediascape.de>
Hi Ben,
Ben Bacarisse schrieb:
>> [...]
>
> It is usually unhelpful to post such output because too many
> components might have messed with it. I'd post a hex dump[1]. For
> example on my system you program's output is:
>
> 00000000 41 c3 84 c3 a4 20 4f c3 96 c3 b6 20 55 c3 9c c3 |A....
O.... U...|
> 00000010 bc 20 73 73 c3 9f |. ss..|
> 00000016
>
> Form this is can see that, as expected, the string is printed
> literally. Your accented characters are UTF-8 encoded in the source,
> and that is how they come out. In fact, because I have my terminal
> character encoding set to UTF-8, you program prints: AÄä OÖö UÜü ssß
> if I view the output directly.
Okay, thanks for that note...
>> [...]
>> The OS is running as a German environment. How can I tell Perl to use
>> the german charset?
>
> OK, but how do you want these characters to be encoded, both in the
> source and in the output? You seem to have chosen UTF-8 for the
> source and if you want the same for the output you will need to have a
> device that is expecting to see that encoding.
I´m creating textfiles from a PHP-frontend, each containing an absolute
path to a file on the filesystem. Normally PHP saves the file in
ASCII-mode, but if there are umlauts in name of the file, PHP saves the
textfile als UTF-8. Then, when I try to read the created textfiles using
perl, the umlauts are mutilated. Watching the textfile I can see that
the path itself has been saved correctly. But Perl seems to read the
file with a different charset.
Meanwhile I added
binmode STDOUT, ':encoding(cp850)';
binmode STDIN, ':encoding(cp850)';
to the script. Being runned it says:
"\x{0084}" does not map to cp850 at actiontaker.pl line 226, <RJ> line 3.
!E:\Freigaben\FILESERVER\allshares\austausch\anke\Vertriebs und
Marketingans\x{0084}tze Everyone:(OI)(CI)F !
Thank you!
Dennis
------------------------------
Date: Tue, 22 May 2007 16:46:55 +0100
From: Ben Bacarisse <ben.usenet@bsb.me.uk>
Subject: Re: Perl and German Umlauts
Message-Id: <87646kuahc.fsf@bsb.me.uk>
Dennis Winter <idontlikespam@denniswinter.de> writes:
> Ben Bacarisse schrieb:
>>> [...]
>>
>> OK, but how do you want these characters to be encoded, both in the
>> source and in the output? You seem to have chosen UTF-8 for the
>> source and if you want the same for the output you will need to have a
>> device that is expecting to see that encoding.
>
> I´m creating textfiles from a PHP-frontend, each containing an
> absolute path to a file on the filesystem. Normally PHP saves the file
> in ASCII-mode, but if there are umlauts in name of the file, PHP saves
> the textfile als UTF-8. Then, when I try to read the created textfiles
> using perl, the umlauts are mutilated. Watching the textfile I can see
> that the path itself has been saved correctly. But Perl seems to read
> the file with a different charset.
>
> Meanwhile I added
>
> binmode STDOUT, ':encoding(cp850)';
> binmode STDIN, ':encoding(cp850)';
That looks wrong. You say the files are UTF-8 encoded so why not give
':utf8' as the layer, at least for input?
--
Ben.
------------------------------
Date: 22 May 2007 10:16:23 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Unicode in regexp
Message-Id: <1179854183.844083.239390@k79g2000hse.googlegroups.com>
On May 21, 12:09 pm, patari <lassi.paavolai...@pp.inet.fi> wrote:
> I have some text which has unicode character \u+2013 for example:
> PERFORMANCE - A COMPARATIVE STUDY
Unicode text is a abstract series of code points.
When you pass Unicode character data from one place to another (e.g.
web form to web server, web server to web browser, application to
database, database to application, file to application, application to
file...) you need the two ends to agree what encoding is being used to
serialise the abstract series of code points into a series of bytes.
Perl has two types of string: Unicode strings and byte strings. Byte
strings contain bytes or, sometimes, ASCII text. There are various
rules about what happens if you treat a byte string containing bytes
in the range 0x80-0xFF a text but I'm not going to go into those here.
You should ideally explicitly say when you want to convert a byte
sequence to a Unicode character sequence and specify what encoding you
are using.
So, when you want to read your sample text (as a series of bytes from
an external source) into a Perl Unicode string you need to make sure
that you tell Perl (somehow) what encoding is being used.
> How can I find this character and change it to two - characters for
> LaTeX?
>
> Somehow next code doesn't work, assuming that $str contains string
> mentioned earlier:
>
> $str =~ s/\x{2013}/--/g;
The code is right the assumption is wrong. $str did not contain U
+2013.
>From evidence elsewhere in this thread I can determine that $str
either was not a Unicode string at all (in which case it contained
only bytes - one of which was 0x96) or it was a Unicode string and
contained U+96.
Now it just so happens that in Latin1 the byte 0x96 encodes the
Unicode code point U+96 and in Windows-1250 the byte 0x96 encodes the
Unicode code point U+2013.
So I conclude that at some point your Unicode text has been passed
from one place to another in such a way that the sender thinks it's
using Windows-1250 encoding and the receiver thinks it's Latin1
encoding. The effect of this is to transform the printable Unicode
characher 'EN DASH' into the non-printable Unicode control character
'START OF GUARDED AREA'.
There is not sufficient evidence presented in this thread to work out
where this corruption occurred.
> If I save that text in a UTF-8 file and open that file like this
> open(FILE,"<:utf8","text.txt");
> then above regular expression works. How could I get regexp to work
> for text that is not read from a file which is specified to be in
> UTF-8 encoding?
By making sure that you know what encoding is being used by the place
that you are reading it from and instructing Perl to decode it if from
that encoding into Unicode.
------------------------------
Date: 22 May 2007 10:16:51 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Unicode in regexp
Message-Id: <1179854210.932636.114860@w5g2000hsg.googlegroups.com>
On May 22, 8:48 am, patari <lassi.paavolai...@pp.inet.fi> wrote:
> On 21 touko, 18:57, "Mumia W." <paduille.4061.mumia.w
>
>
>
> +nos...@earthlink.net> wrote:
> > On 05/21/2007 06:09 AM, patari wrote:
>
> > > [...]
> > > Somehow next code doesn't work, assuming that $str contains string
> > > mentioned earlier:
>
> > > $str =~ s/\x{2013}/--/g;
>
> > > If I save that text in a UTF-8 file and open that file like this
> > > open(FILE,"<:utf8","text.txt");
> > > then above regular expression works. How could I get regexp to work
> > > for text that is not read from a file which is specified to be in
> > > UTF-8 encoding?
>
> > Where does the text come from?
>
> > How do you know that u+2013 is in that text?
>
> Text comes originally from user of cgi application, but in this case
> the text is fetched from database. I know that character u+2013
> because the text is viewed with browser where it shows, and I can copy
> that for example to emacs which tells me the code of the character.
That is a bad inference.
------------------------------
Date: 22 May 2007 10:22:15 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Unicode in regexp
Message-Id: <1179854535.425520.194420@q69g2000hsb.googlegroups.com>
On May 22, 9:50 am, patari <lassi.paavolai...@pp.inet.fi> wrote:
> I first encoded the string
> my $octets = encode("UTF-8",$str);
> and then printed it to Apaches log. The character seemed to be encoded
> \xc2\x96.
Which tells us that the character is U+96.
> I'm still wondering why \x{2013} didn't match after encode.
encode() returns a byte string. It contains only bytes. \x{2013} is
not a byte so it can never exist in a byte string.
> It seems
> that encode also changes that character and in this case codes it as
> \xc2\x96.
No, there's no reason to believe that $str ever contained U+2013
------------------------------
Date: 22 May 2007 10:24:18 -0700
From: Brian McCauley <nobull67@gmail.com>
Subject: Re: Unicode in regexp
Message-Id: <1179854658.025401.324020@q66g2000hsg.googlegroups.com>
On May 21, 1:37 pm, gypa...@gmail.com wrote:
> use Encode;
> $octets = decode("UTF-8", $str);
Your variable naming is confusing. decode() takes an byte (aka octet)
string as an argument and returns a string of Unicode characters (not
a string of bytes).
------------------------------
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 452
**************************************