Hi,
I need to get the number of keys in an hash. Is there any convenient way to
get it?
or use the following one?
foreach $v (keys %hash){
$count++;
}
Thanks in advance,
Liang 7 33124
Liang wrote: Hi,
I need to get the number of keys in an hash. Is there any convenient way to get it?
or use the following one? foreach $v (keys %hash){ $count++; }
Oh dear, that's a rather creative way....
Trivial. Just use "keys(%hash)" in scalar context, e.g.
my $number = keys %hash;
jue
"Liang" <le*********@hotmail.com> wrote in message news:<cg**********@newshost.mot.com>... Hi,
I need to get the number of keys in an hash. Is there any convenient way to get it?
or use the following one? foreach $v (keys %hash){ $count++; }
Thanks in advance, Liang
Try
$keyCount=(%keys %hash);
"Liang" <le*********@hotmail.com> wrote in message news:<cg**********@newshost.mot.com>... Hi,
I need to get the number of keys in an hash. Is there any convenient way to get it?
Yes, the keys() function.
or use the following one? foreach $v (keys %hash){ $count++; }
No, that is not necesary.
This newsgroup does not exist (see FAQ). Please do not start threads here.
Thanks in advance,
If you are going to do any things "in advance" then my suggestions would be:
1) Check the FAQ.
2) Check the documentation for the functions you are using.
Everyone says "See FAQ". Could you please include the URL to the FAQ?
Be kind to newbies......You used to be one.
-s no****@mail.com wrote: "Liang" <le*********@hotmail.com> wrote in message news:<cg**********@newshost.mot.com>... Hi,
I need to get the number of keys in an hash. Is there any convenient way to get it?
Yes, the keys() function.
or use the following one? foreach $v (keys %hash){ $count++; }
No, that is not necesary.
This newsgroup does not exist (see FAQ). Please do not start threads here.
Thanks in advance,
If you are going to do any things "in advance" then my suggestions would be:
1) Check the FAQ. 2) Check the documentation for the functions you are using.
Steve Bennett wrote: Everyone says "See FAQ". Could you please include the URL to the FAQ?
What happens when you do a Google search on "perl faq"?
Newbies are expected to know that Google is their friend.
Steve Bennett wrote: Everyone says "See FAQ". Could you please include the URL to the FAQ?
No need for a URL, it's on your own harddrive (after you installed Perl)
Just type
perldoc perlfaq
Be kind to newbies......You used to be one.
You also seem to be new to Usenet. It is considered rude to
- top post
- blindly full quote
For an explanation of what that is and why it's considered rude please
search www.google.com
jue
Steve Bennett rudely spits TOFU in may face: Everyone says "See FAQ". Could you please include the URL to the FAQ?
You are supposed to look for a FAQ _before_ you ask a question. It
would defeat the purpose if the FAQ was so hard to find that asking
where it was was a ligitimate question. Anything you could reasonably
imagine doing to locate the Perl FAQ will succede in about fifteen
seconds.
Be kind to newbies.
I am. Teaching newbies that selfishness is rewarded is _not_ a
kindness. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Tommo |
last post by:
Hello All,
I have a slight problem that goes like this. I have created
a Perl hash where the keys are made up of numeric values, I was then
sorting the 'keys' for this hash on their value (a<=>b...
|
by: VK |
last post by:
A while ago I proposed to update info in the group FAQ section, but I
dropped the discussion using the approach "No matter what color the cat
is as long as it still hounts the mice". Over the last...
|
by: amywolfie |
last post by:
This is an interesting one.....
I have a field on FORM!FORMDATA (no, I did not name this) called KEY.
There can be multiple KEYS per record (equates to FIELDS on a given
DOCUMENT).
The...
|
by: Jovo Mirkovic |
last post by:
Hi,
I have to make a program which will generate 100,000 different ID
numbers (for example 2345-9341-0903-3432-3432 ...) It must be really
different, I meen it can not be a similar (like...
|
by: kdotsky |
last post by:
Hello,
I am using some very large dictionaries with keys that are long strings
(urls). For a large dictionary these keys start to take up a
significant amount of memory. I do not need access to...
|
by: ravi |
last post by:
Hi
can anybody tell me that which ds will be best suited to implement a
hash table in C/C++
thanx. in advanced
|
by: numberwhun |
last post by:
Ok, I have a ".csv" file that contains two lines (VERY LONG lines). Basically, the first line is the headers defining what each field in the second line is.
ie:
Name1,Name2,Name3,...........
|
by: pavanponnapalli |
last post by:
hi ,
I have got a code as under :
sub dbcall
{
my %hash;
my $i=0;
print "<<<<<<<@_>>>>>>> \n";
foreach(@_)
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| |