Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re: Return array from sub or return empty array

by Cow1337killr (Monk)
on Jul 05, 2016 at 03:28 UTC ( [id://1167199]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub somefunc_for_scalars {
        my $answer = some_class->some_method();
        return defined($answer) ? $answer : ''; 
    }
    
  2. or download this
    sub somefunc_for_arrays {
        my @answer = get_array2();
        return @answer; 
    }
    
  3. or download this
    sub somefunc_for_arrays {
        my @answer = get_array2();
        if (!(scalar @answer)) { die 'get_array2() returned an empty array
    +.' }.
        return @answer; 
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1167199]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (2)
As of 2024-04-25 20:09 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found