On Thu, Nov 22, 2018 at 12:33:25PM -0800, John W. Krahn wrote:
> On 2018-11-22 8:08 a.m., David Precious wrote:
> > 
> > You'll often see these operators used to provide default values.
> > 
> > e.g.
> > 
> >    sub hello {
> >        my $name = shift;
> >        $name ||= 'Anonymous Person';
> 
> Which is usually written as:
> 
>    sub hello {
>        my $name = shift || 'Anonymous Person';

Or, nowadays, and if your perl version(s) support it, as:

    sub hello ($name = "Anonymous Person") {

-- 
Paul Johnson - p...@pjcj.net
http://www.pjcj.net

-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to