How do we get the length of a variable in bytes?
I see the length function returns length in characters. 
unless you (From perldoc -f length):
           use "do { use bytes; length(EXPR) }"

Nothing there would seem to indicate it cannot be used to get the
length in characters or bytes of an array.

It does say:
   . . . . . . . . . . . . . . . . . Note that this cannot be
   used on an entire array or hash to find out how many elements
   these have.  For that, use "scalar @array" and "scalar keys
   %hash" respectively.

But that doesn't appear to preclude using it to get the length in
characters.  But apparently you cannot since this returns <1>.
  my @ar = ("one,","two","three","four","five");
  my $char = length @ar;
  print "char<$char>\n"
  
  char<1>

There is a reference right at the end that might be pointing at what I'm
looking for but I can't understand what it means:

  . . . . . . . . . . . . . . . . . . . . . . . .To get the  
  length in bytes, use "do { use bytes; length(EXPR) }", see
  bytes.

What is meant by `see bytes'?  Since it appears in function
documentation it seems to indicate there is a function called `bytes'
or at least something in the FAQ.

But here, neither `perldoc -f' bytes nor `peldoc -q bytes' shows
anything.


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to