perl.beginners
  Home FAQ Contact Sign in
perl.beginners only
 
Advanced search
July 2008
motuwethfrsasuw
 123456 27
78910111213 28
14151617181920 29
21222324252627 30
28293031    31
2008
 Jan   Feb   Mar   Apr 
 May   Jun   Jul   Aug 
 Sep   Oct   Nov   Dec 
2008 2007 2006  
total
perl.beginners Profile…
RELATED GROUPS

POPULAR GROUPS

more...

 Up
  RE: using mysql NULL with IF statement         


Author: T Baetzler
Date: Jul 13, 2008 23:56

Huub gmail.com> asked:
> I'm adapting a Perl script using MySQL connectivity, and have
> to compare a variable, e.g. $myvar, with the value NULL from
> the database. In MySQL, I have to use the query 'where myvar
> is null', which works great.
> But when I try this in Perl, like 'if ($myvar == null)' or
> 'if ($myvar is null)' it ends in error. I read the DBI FAQ on
> this, but didn't find an example of IF and NULL. Can somebody
> tell me how I can or should do this?

See the DBI manpage, Subsection "Notation and Conventions":
"NULL values are represented by undefined values in Perl".

You check that by using statements like

if( defined( $myvar ) )

HTH,
Thomas
no comments
  question about "local our"         


Author: Roman Makurin
Date: Jul 13, 2008 20:17

Hi All!

I want to ask whats difference between usage of "local" and "local our"

Here is example code:

#!/usr/bin/perl

use strict;
use warnings;

our $i = 0;

sub t_func1 {
local $i = 1;
print "\$i = $i\n";
}

sub t_func2 {
local our $i = 2;
print "\$i = $i\n";
}

t_func1();
t_func2();
print "\$i = $i\n";
Show full article (0.45Kb)
2 Comments
  using mysql NULL with IF statement         


Author: Huub
Date: Jul 13, 2008 12:54

Hi,

I'm adapting a Perl script using MySQL connectivity, and have to compare
a variable, e.g. $myvar, with the value NULL from the database. In
MySQL, I have to use the query 'where myvar is null', which works great.
But when I try this in Perl, like 'if ($myvar == null)' or 'if ($myvar
is null)' it ends in error. I read the DBI FAQ on this, but didn't find
an example of IF and NULL. Can somebody tell me how I can or should do this?

Thanks.
2 Comments