Wantarray function. : Context « Subroutine « Perl






Wantarray function.

   
#!/usr/local/bin/perl 

@array = &mysub(); 
$scalar = &mysub(); 

sub mysub { 
    if (wantarray()) { 
        print ("true\n"); 
    } else { 
        print ("false\n"); 
    } 
} 

   
    
    
  








Related examples in the same category

1.Return value based on context
2.Scalar and list Context
3.Context and Subroutines