how to validate the string is Chinese only?

2011-03-09 Thread terry peng
Hello, I got the form value from web client, and I want to validate the value string include Chinese words only. How to do this? Thanks in advance. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Thanks for the reading suggestions! Brian Fraser wrote: On Wed, Mar 9, 2011 at 2:22 PM, Brian F. Yulga mailto:byu...@langly.dyndns.org>> wrote: Uri and Jim have hit upon one of my major stumbling blocks with learning Perl. There seems to be a difference of opinion on the proper ti

Re: Using regex special characters from a string

2011-03-09 Thread Brian Fraser
On Wed, Mar 9, 2011 at 2:22 PM, Brian F. Yulga wrote: > Uri and Jim have hit upon one of my major stumbling blocks with learning > Perl. There seems to be a difference of opinion on the proper times to use > hashes vs. arrays/lists...and how best to use them. http://perldoc.perl.org/perlfaq4.ht

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Ben Lavery wrote: > there must be a slight trade-off... the processing required to > initialize the hash table with it's keys and values is probably > more intensive than defining an array with its respective values? > Unless, internally, Perl stores arrays as hashes, with the indexes > as the ke

Re: Using regex special characters from a string

2011-03-09 Thread Ben Lavery
> there must be a slight trade-off... the processing required to initialize the > hash table with it's keys and values is probably more intensive than defining > an array with its respective values? Unless, internally, Perl stores arrays > as hashes, with the indexes as the keys. I would have

Re: Using regex special characters from a string

2011-03-09 Thread Ben Lavery
On 9 Mar 2011, at 03:01, Ben Lavery wrote: > I shall change from a hash to an array and use grep, or looking into it I may > use List::MoreUtils as it has a "first_value" sub which should make it > somewhat more efficient. OK, so about an hour after I wrote this I was on the train home thinking

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Jim Gibson wrote: On 3/9/11 Wed Mar 9, 2011 9:22 AM, "Brian F. Yulga" scribbled: > > foreach ( @word_list ) { if ( /^$temp_word$/i ) { push( > @all_combinations, ( $_ )); } } That is pretty much what the grep function is doing. It has to iterate over the entire array and evaluate its code

Re: Using regex special characters from a string

2011-03-09 Thread Jim Gibson
On 3/9/11 Wed Mar 9, 2011 9:22 AM, "Brian F. Yulga" scribbled: > Uri and Jim have hit upon one of my major stumbling blocks with learning > Perl. There seems to be a difference of opinion on the proper times to > use hashes vs. arrays/lists...and how best to use them. For those that > have he

Re: multidimensional array check

2011-03-09 Thread Jim Gibson
On 3/9/11 Wed Mar 9, 2011 8:46 AM, "vito pascali" scribbled: > > The results of u script are: > > Overlap: alfa > Unique: gamma, beta > Remains: beta > > What I need is really different: > > Overlap have to be: alfa,10 (couse the couple is already in @G1 and @L1); > Unique have to be: bet

Re: Using regex special characters from a string

2011-03-09 Thread Brian F. Yulga
Uri Guttman wrote: >> "BL" == Ben Lavery writes: > > > BL> #Here, using a hash looks much cleaner than iterating through an array > > hashes are almost always better for token lookups than scanning > arrays. don't doubt yourself in this area. > > Jim Gibson wrote: > On 3/8/

Re: multidimensional array check

2011-03-09 Thread vito pascali
Can you explain exactly what the your rules are? You seem to be saying > that ["alfa", "10"] and ["alfa", "10"] belong in 'overlap' because they > are identical, which is fair enough. But by what criterion do > ["gamma", "12"] and ["gamma"] belong in the same list? Would ["alfa"] > belong there to

Re: multidimensional array check

2011-03-09 Thread vito pascali
> > Can you explain exactly what the your rules are? You seem to be saying > that ["alfa", "10"] and ["alfa", "10"] belong in 'overlap' because they > are identical, which is fair enough. But by what criterion do > ["gamma", "12"] and ["gamma"] belong in the same list? Would ["alfa"] > belong there

Re: multidimensional array check

2011-03-09 Thread Rob Dixon
On 09/03/2011 14:03, vito pascali wrote: Tnx a lot for u tips!! I just used all (or almost all) u suggestion, but what i really need is some help in the "logic" of the script. I mean at the moment I have this 3 arrays: @G1 = (["alfa" , "10"], ["beta" , "11"]); @L1 = (["alfa" , "10"], ["g

Re: multidimensional array check

2011-03-09 Thread vito pascali
Tnx Jim! I was looking at u script but still is not what I need: > > > > #!/usr/bin/perl > use strict; > use warnings; > > my @G1 = (["alfa" , "10"], ["beta" , "11"]); > my @L1 = (["alfa" , "10"], ["gamma" , "12"]); > my @G2 =('gamma'); > > # populate a hash with the elements of G1 > my %un

Re: multidimensional array check

2011-03-09 Thread Jim Gibson
At 3:03 PM +0100 3/9/11, vito pascali wrote: Tnx a lot for u tips!! I just used all (or almost all) u suggestion, but what i really need is some help in the "logic" of the script. I mean at the moment I have this 3 arrays: @G1 = (["alfa" , "10"], ["beta" , "11"]); @L1 = (["alfa" , "10"], [

Re: multidimensional array check

2011-03-09 Thread vito pascali
Tnx a lot for u tips!! I just used all (or almost all) u suggestion, but what i really need is some help in the "logic" of the script. I mean at the moment I have this 3 arrays: @G1 = (["alfa" , "10"], ["beta" , "11"]); @L1 = (["alfa" , "10"], ["gamma" , "12"]); @G2 =('gamma'); I need to