Actually, I think that part is fine. @myvalues is an array containing one
reference to an array. [] makes a refernce to an anonymous array. Thus the
foreach will iterate once and @$myvalue deferences it to an array with two
values: ( 5, undef ). I think perl is bithin' about the undef in the array.
For instance:
[218] mrna:/home/harsch/classes/010629> perl -wde 0
Loading DB routines from perl5db.pl version 1.03
Emacs support available.
Enter h or `h h' for help.
main::(-e:1): 0
DB<1> @a = ( 5, undef );
DB<2> print @a
Use of uninitialized value at (eval 5) line 2, <IN> chunk 2.
eval '($@, $!, $^E, $,, $/, $\\, $^W) = @saved;package main; $^D =
$^D | $DB::db_stop;
print @a;
;' called at /usr/local/perl5.005/lib/perl5db.pl line 1231
DB::eval called at /usr/local/perl5.005/lib/perl5db.pl line 1126
DB::DB called at -e line 1
5
DB<3>
> -----Original Message-----
> From: Mark Stosberg [mailto:[EMAIL PROTECTED]]
> Sent: Thursday, June 28, 2001 5:36 PM
> To: Tim Harsch
> Cc: [EMAIL PROTECTED]
> Subject: Re: -w does not allow undef for NULLs
>
>
> Tim Harsch wrote:
> >
> > how do you use undef when you mean to without -w barking this at you:
> > Use of uninitialized value at
> > /usr/local/perl5.005/lib/site_perl/DBD/Sybase.pm line 121.
> >
> > code snip:
> > $hDB->do( <<SQL );
> > create table #temp_for_this_session
> > ( fld1 int not null,
> > fld2 varchar(20) null )
> > SQL
> >
> > my @myvalues = (
> > [ 5, undef ],
> > );
> >
> > foreach my $myvalue ( @myvalues ) {
> > my $sql = 'insert into #temp values ( ?, ? )';
> > $hDB->do( $sql, {}, @$myvalue );
> > } # end foreach
> >
> > __END__
> >
> > I'm supposed to use undef to indicate NULL in the database
> right? Should
> > Sybase.pm be checking for undef before trying to use the value?
>
> I think you need to remove the leading "@" on @$myvalue. That deferences
> $myvalue as an array there, when you just need a scalar. I think it's
> complaining because you are trying to use undef as an array reference.
>
> -mark
>
>
> http://mark.stosberg.com/
>