perl.beginners
[Top] [All Lists]

Re: return scalar or list

Subject: Re: return scalar or list
From:
Date: Thu, 5 Nov 2009 22:32:56 +0800
Newsgroups: perl.beginners

Thanks all. Just forgot these... :)
How to make a subroutie, if the caller doesn't pass an argument to it,
use $_ instead? like "print" doing.


2009/11/5 Shlomi Fish <shlomif@xxxxxxxxxxx>:
> On Thursday 05 Nov 2009 16:09:47 兰花仙子 wrote:
>> How to make a subroutine, if the caller is in scalar context, returns
>> a scalar, if the caller is in list context, returns a list.
>> Like most of Perl's built-in functions doing. Thanks.
>>
>
> See perldoc -f wantarray :
>
> http://perldoc.perl.org/functions/wantarray.html
>
> A small example based on that page:
>

<Prev in Thread] Current Thread [Next in Thread>