if condition in perl

pvinodp
pvinodp used Ask the Experts™
on
sub func1()
my $input = shift;
if (check $input is null... not initialized)
   return NULL;

else
 execute something else

I need help in writing the part enclosed in bold.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
ozo
Most Valuable Expert 2014
Top Expert 2015
Commented:
return undef unless defined $input;
if ($str eq '') {
  return NULL;
}

Author

Commented:
but does perl support null
Exploring SQL Server 2016: Fundamentals

Learn the fundamentals of Microsoft SQL Server, a relational database management system that stores and retrieves data when requested by other software applications.

ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
There seem to be different interpretations of the question, so maybe some clarification is in order.
null or NULL are not keywords in Perl, so do you mean an empty string?  by "not initialized" do you mean undef?
ozo
Most Valuable Expert 2014
Top Expert 2015

Commented:
>but does perl support null
what characteristics do you want this null to have?

Author

Commented:
It is very similar to the object created in java.
class obj; // state 1
obj = new class(); // state 2

I  need to check in the if condition whether the $input is in obj's state 1
Most Valuable Expert 2014
Top Expert 2015
Commented:
That seems similar to undef, which can be checked with the defined function

Author

Commented:
Thanks ozo

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial