how to check null value
am 22.04.2008 10:09:19 von Irfan.Sayed
------_=_NextPart_001_01C8A450.2B09AF70
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: quoted-printable
Hi All,
=20
How to find out whether the string contains null values or empty data.
=20
For example : I have one scalar variable $str and now I want to check
whether it contains any data or not.
=20
What I did : If ($str eq "NULL" || $str eq " "){ print $str conatins
nothing\n";}
=20
Is this correct?? Because doing as per above code , I am not getting
proper result.
=20
Please help
=20
Regards,
Irfan
=20
------_=_NextPart_001_01C8A450.2B09AF70--
Re: how to check null value
am 22.04.2008 11:54:16 von igotux igotux
------=_Part_4590_30846289.1208858056309
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline
perldoc -f defined should answer your question.
On Tue, Apr 22, 2008 at 1:39 PM, wrote:
> Hi All,
>
>
>
> How to find out whether the string contains null values or empty data.
>
>
>
> For example : I have one scalar variable $str and now I want to check
> whether it contains any data or not.
>
>
>
> What I did : If ($str eq "NULL" || $str eq " "){ print $str conatins
> nothing\n";}
>
>
>
> Is this correct?? Because doing as per above code , I am not getting
> proper result.
>
>
>
> Please help
>
>
>
> Regards,
>
> Irfan
>
>
>
>
------=_Part_4590_30846289.1208858056309--
Re: how to check null value
am 22.04.2008 12:02:02 von Lars Haugseth
* Irfan.Sayed@t-systems.com wrote:
>
> How to find out whether the string contains null values or empty data.
>
> For example : I have one scalar variable $str and now I want to check
> whether it contains any data or not.
>
> What I did : If ($str eq "NULL" || $str eq " "){ print $str conatins
> nothing\n";}
Try this:
if (!defined $str || $str eq "") { ... }
Almost but not quite the same:
if (!$str) { ... }
Here the block will also be executed if the value of $str is 0.
--
Lars Haugseth
"If anyone disagrees with anything I say, I am quite prepared not only to
retract it, but also to deny under oath that I ever said it." -Tom Lehrer
--
To unsubscribe, e-mail: beginners-unsubscribe@perl.org
For additional commands, e-mail: beginners-help@perl.org
http://learn.perl.org/