Re: Big unicode problem with Perl 5.8.8 with MySQL 5.0 (i.e. Debian 4.0)

2007-08-31 Thread Karjala
Thanks, I solved the problem by following the advice on the second 
comment on this page: 
http://dev.mysql.com/doc/refman/5.0/en/charset-connection.html



Chas Owens wrote:

On 8/29/07, Karjala <[EMAIL PROTECTED]> wrote:
snip
  

I'm desperate for a solution, a hint, or if you run Debian to please try
these short scripts on your machine to tell me whether you're getting
the same results (or better ones).


snip

Have you tried doing the insert from the mysql command to see if it is
the database that is at fault and not Perl?

You probably are already aware of this url, but I am including it just
case you haven't read this stuff:
http://www.mysql.org/doc/refman/5.0/en/charset.html

  




Big unicode problem with Perl 5.8.8 with MySQL 5.0 (i.e. Debian 4.0)

2007-08-29 Thread Karjala
I just upgraded from Debian 3 (Perl 5.8.4 and MySQL 4.1) to Debian 4 
(Perl 5.8.8 and MySQL 5.0 and DBD::mysql 3.0008) and have the following 
problem:


In the following lines I create a table with a char field of length 4 
and then try, using a perl script, to populate it with a string of 4 
unicode characters, and see that only the 2 first characters have been 
stored, in a "double-encoded" form (thus taking the space of 4 
characters). Needless to say, this is a huge problem.



First the table:

mysql> create table bbb (a int primary key auto_increment, b varchar(4));
Query OK, 0 rows affected (0.00 sec)


Then the perl script to populate the field:

#!/usr/bin/perl -w
use DBI;
my $dbh = DBI->connect("DBI:mysql:aaa", 'username', 'password', { 
RaiseError => 1 });

$dbh->do("insert into bbb set b = 'Αθήν'");


And then checking the result:

mysql> select * from bbb;
+---++
| a | b  |
+---++
| 1 | ΡÆθ  |
+---++
1 row in set (0.00 sec)


That was with default_character_set=utf8 under the [mysql] section of 
my.conf.


Commenting out that line and viewing the table again, we get:

mysql> select *, char_length(b) from bbb;
+---+--++
| a | b| char_length(b) |
+---+--++
| 1 | Αθ |  4 |
+---+--++
1 row in set (0.00 sec)


i.e. we only got the first two letters in the table, but doubly-encoded 
to take up the space of 4 chars.


I'm desperate for a solution, a hint, or if you run Debian to please try 
these short scripts on your machine to tell me whether you're getting 
the same results (or better ones).


Thanks.

P.S. I'm 99.9% positive I've made sure the problem is not at my 
terminal's encoding, by uploading the perl script from another machine 
(that's known to have no problem) and inserting a 'use encoding "utf8";' 
pragma as well.


And thanks again.

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: XML Parsing

2007-06-26 Thread Karjala

Mike Blezien wrote:
can this handle multiple elements with the same name? IE. the path 
used above may have more then one  element within 
the  ...  ...  



Mike



It can, as follows:


   my @message_objects = 
$obj->path('response/idalertresponse/candidateresults/candidateactivity/messaging/raiserisklevel/message');


   foreach my $msg_obj (@message_objects) {
  print $msg_obj->value();
   }





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Re: XML Parsing

2007-06-26 Thread Karjala
You could use XML::MyXML for this job (works well), if you know the 
exact position in the XML tree where  is located.


Say $xml holds your XML.

Then:

   use XML::MyXML qw(:all);

   $obj = &xml_to_object($xml)
   $msg_obj = 
$obj->path('response/idalertresponse/candidateresults/candidateactivity/messaging/raiserisklevel/message');

   $message = $msg_obj->value();

   print $message;



Mike Blezien wrote:
  





--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/




Creating RSS feeds with Perl?

2006-10-11 Thread Karjala

How do you create your websites' RSS feeds?

I run a script called createrss.pl as a cron job every hour which checks 
if there are any new stories and if so creates a new feed.rss file


I think this method takes up a lot of RAM and CPU power since it 
launches Perl every hour, but I can't think of anything better.


The other way I thought of (and rejected) was to have the web script 
that accepts a new story from the administrator, to also create the RSS 
file. But I rejected this because if two people might submit a story at 
the same time then the resulting RSS file might only contain one of them.


So, how do you do it?

- Kar


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




MySQL question

2006-07-21 Thread Karjala
Maybe I should ask this question on a database list, but it's related to 
DBI, so I'm asking here also:


I have a field in a record in the MySQL database that contains a number.

I increase it by one with $dbh->do("update table set myfield = myfield + 
1 where mykey = 10");


I was wondering whether there's a way to find out the value of myfield 
right after the update.


Running a "select myfield" right after the update is not a good enough 
solution to my problem, since this is a web-based application, and 
therefore it's possible that myfield might increase again between the 
time of the first update and the select.


Do you know of any solution to this problem?


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: hashref ref ref slice

2006-05-03 Thread Karjala

And this will work also:

map {$tmp->{$_}->{text}} @sortedkeys


Karjala wrote:

Try this:
map {$_->{text}} @[EMAIL PROTECTED]

Ryan Perry wrote:

@[EMAIL PROTECTED]>{text}

I want to get all the "text" values for a set of keys in a hashref, 
but the above code always gives me only the first in @sortedkeys.


Thanks for any assistance!

Ryan

--To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>












--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Re: hashref ref ref slice

2006-05-02 Thread Karjala

Try this:
map {$_->{text}} @[EMAIL PROTECTED]

Ryan Perry wrote:

@[EMAIL PROTECTED]>{text}

I want to get all the "text" values for a set of keys in a hashref, 
but the above code always gives me only the first in @sortedkeys.


Thanks for any assistance!

Ryan

--To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 








--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Java/Perl

2006-04-30 Thread Karjala

Has anyone used the "Java" module successfully in Perl?

If yes, I will post my very basic question.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Re: Interprocess communications for Windows Perl

2006-04-19 Thread Karjala

I guess then sockets is the right way for my case.

Thanks.

zentara wrote:

Personally, I would stick with sockets, since it is more foolproof
and well tested.
  




--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
 




Interprocess communications for Windows Perl

2006-04-18 Thread Karjala
I'm making a Perl program, and someone else is writing a C++ program, 
and both will run on the same MS-Windows machine at the same time.


What is a good way to have the two programs communicate?

I'm asking because until now I've only programmed for Linux machines, 
and I used to use named pipes for IPC (Interprocess communication) 
because they were easy to use and made the Perl programs much shorter 
than with TCP/IP sockets.


Does MS-Windows support named pipes in a similar way to Linux? Are there 
any modules that you would recommend for Windows IPC?


Thanks,
- Karjala


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Create ODBC driver?

2006-04-14 Thread Karjala
Is there a Perl module that can help me create my own ODBC driver for 
Windows?


I haven't found any on CPAN, but it could be a good idea to have one.

For example, I need a special kind of ODBC driver that instead of 
issuing SQL statements to a database, issues SOAP statements to a website.


It would be nice if I could create such an ODBC driver with Perl.

- Karjala


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




How to detect if the other end of the TCP connection has gone offline

2005-10-31 Thread Karjala
I'm writing a simple client-server application, and I'm trying to find a 
way to tell if the other end of an open TCP connection has gone offline.


I heard that with C you can send a packet of data and check if an ACK 
packet comes back. If it doesn't then the connection is closed. But how 
can that be done with Perl?


I'm using the "IO::Socket" library, but if "Socket" can do it, I'm 
willing to revert to that.


Thanks for your time,
- Karj.


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]