[Chicago-talk] undef values in arrays.

Andy Lester andy at petdance.com
Thu Sep 11 19:32:21 PDT 2008


> The array is a result of this statement:
> my @a = $sth_s->fetchrow_array
>
> I presume I have a NULL value in my database and it come back as a
> undef in the array.

Don't presume.

use Data::Dumper;
print Dumper( \@a );


> Anyway, Is there a graceful way to replace the udef values in @a with
> the string "<NULL>"?

@pretty = map { defined $_ ? $_ : '<NULL>' } @a;

xoa

--
Andy Lester => andy at petdance.com => www.petdance.com => AIM:petdance






More information about the Chicago-talk mailing list