By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,372 Members | 1,906 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,372 IT Pros & Developers. It's quick & easy.

Lenght of scalar, sizeof scalar

P: 62
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
Share this Question
Share on Google+
5 Replies


Ganon11
Expert 2.5K+
P: 3,652
1) Try perldoc -f length

2) Not sure.
Oct 12 '08 #2

numberwhun
Expert Mod 2.5K+
P: 3,503
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

P: 62
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 2.5K+
P: 4,059
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 2.5K+
P: 4,059
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.