467,926 Members | 1,747 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,926 developers. It's quick & easy.

Lenght of scalar, sizeof scalar

Hi!

1, How can I quevery the stringlenght of a scalar
(like in C the function : strlen() )
2,How can I quevery the sizeof a scalar
(like in C the operator: sizeof )

Thanks!
Oct 12 '08 #1
  • viewed: 3990
Share:
5 Replies
Ganon11
Expert 2GB
1) Try perldoc -f length

2) Not sure.
Oct 12 '08 #2
numberwhun
Expert Mod 2GB
I think that the two are one in the same. Length is size. With regards to arrays, you could be speaking of the length of the array (which would be the number of elements in the array) and the size (length) of each element.

Regards,

Jeff
Oct 12 '08 #3
I think that the two are one in the same. Length is size. With regards to arrays, you could be speaking of the length of the array (which would be the number of elements in the array) and the size (length) of each element.

Regards,

Jeff
Thanks but I dont think they are same.

Example:

Expand|Select|Wrap|Line Numbers
  1. print($strlen=length($string=232));
  2.  
it give at display 3,(3number), but the number 232 take from memory only 2 bytes.
when you think so the two is same

Thanks
Oct 12 '08 #4
KevinADC
Expert 2GB
perl has no builtin function that is the same as the C sizeof function. Perl handles all memory management for you, you don't have to allocate memory with perl or manage it.
Oct 12 '08 #5
KevinADC
Expert 2GB
If you want to know variable sizes this module should help you:

Devel::Size

But like I said, you don't have to manage memory or allocate memory with perl.
Oct 12 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

2 posts views Thread by Kevin Auch | last post: by
5 posts views Thread by Bob Stearns | last post: by
5 posts views Thread by Eli | last post: by
9 posts views Thread by Andrey Koptyaev | last post: by
2 posts views Thread by venu reddy | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.