Hi, 

> I can't really figure out what the purpose of wantarray() is.
> Can someone please give me a good, decent explanation?

wantarray() returns true if the context of the actual subroutine
expects a list as return value(s).

sub do_something {

  my $arg = shift;
  do_something ....  and stuff it in @some_array
  
  return wantarray ? @some_aray : $some_array[0];

}

@array = &do_something($arg);
Result: @array contains @some_array

$array =  &do_something($arg);
Result: $array contains first element of @some_array

HTH,
Jan
-- 
cat /dev/world | perl -e "while (<>) {(/(^.*? \?) 42 \!/) && (print $1)}"
errors->(c)
- 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to