Sorting hash values

2006-04-05 Thread Baskaran Sankaran
Hi group, I am trying to process a hash (words as keys and frequency counts in an array as values). Instead of just sorting it by values, I want to sort it by the probabilities and I tried this... foreach $rule (sort {\compute_probability($b) = \compute_probability($a)} keys %rules_new) {

RE: store Array in hash ?

2006-03-30 Thread Baskaran Sankaran
You can try this. $test-{$setup}-{'data'} = [$data[0], $data[1]]; As you said reference is not going to work, if your array value changes at run time. You can also access specific elements of the array individually, whenever required. Baskaran From:

Tree:Nary and Unicode

2006-03-20 Thread Baskaran Sankaran
Hi group, My Unicode blues continues… One more question on handling Unicode. Does Tree::Nary module works with Unicode data? I am trying to store some Unicode strings (UTF-8 to be precise) as Nary Tree. When I retrieve the value of the nodes from the tree, it produces the output as

RE: Tree:Nary and Unicode

2006-03-20 Thread Baskaran Sankaran
-Original Message- From: Mr. Shawn H. Corey [mailto:[EMAIL PROTECTED] Sent: 20 March 2006 16:25 To: beginners@perl.org Subject: Re: Tree:Nary and Unicode Baskaran Sankaran wrote: use Tree::Nary; use warnings; open(O, children.txt); binmode (O, :utf8); open(I

Regular expression - Global substitution

2006-03-13 Thread Baskaran Sankaran
Hi Group, Am working with Unicode (UTF8 coded) stuff and facing problem with regular expression. s/(\p{HinNumerals})\s+($tokenize_string)+\s+(\p{HinNumerals})/$1$2$3/g; and, my HinNumerals is defined as, sub HinNumerals { return END; 0966\t096F END }

RE: FW: Reading a Unicode text file

2006-03-08 Thread Baskaran Sankaran
:56 To: Baskaran Sankaran Cc: beginners@perl.org Subject: Re: FW: Reading a Unicode text file On 2/17/06, Baskaran Sankaran [EMAIL PROTECTED] wrote: File: Sample_Hin.txt दूसरे राज्य पुनर्गठन आयोग के गठन का यही सही वक्त है। The sample files were created in Windows in Unicode (both

FW: Reading a Unicode text file

2006-02-17 Thread Baskaran Sankaran
Hi group, Opening a file for output is fine. I've also moved the binmode immediately after open, outside the loop. But, the error still shows. Now, here are the sample files and my command would be: perl number_sent.pl Sample_Eng.txt Sample_Hin.txt Sample_out.txt File:

RE: Reading a Unicode text file

2006-02-16 Thread Baskaran Sankaran
Subject: Re: Reading a Unicode text file Baskaran Sankaran wrote: Thanks for that but still I do face problem. I did that and it raises a warning: utf8 \xFF does not map to Unicode at second.pl line 8, $lang_sample_fh line 1. Excellent, so now we have soem info to start

Practical Unicode handling in Perl

2006-02-16 Thread Baskaran Sankaran
Hi group, Is there a source for practical Unicode handling in Perl with example programs (sort of cook book will be useful)? Man pages like perlunicode, perluniintro are fine but I feel they are far less than practical. Any pointers would be great. Thanks, Baskaran

Reading a Unicode text file

2006-02-09 Thread Baskaran Sankaran
Hi, I am trying to read a Unicode text file and the code fragment is as below: $infile = sample_hindi.txt; $outfile = out.txt; open(F, :utf8, $infile); while(F) { chomp; binmode ( STDOUT, :utf8 ); print $_; } close(F); The output correctly displays only the