in reply to split, Use of uninitialized value

The code below will suppress the warnings, but your question is so vague that it almost surely won't accomplish the desired end. What is going on?
$rec->[IMP_WG] = defined $rec->[IMP_WG] ? $rec->[IMP_WG] : ''; $rec->[CSC_HAN] = defined $rec->[CSC_HAN] ? $rec->[CSC_HAN] : ''; $rec->[CLASSIF] = defined $rec->[CLASSIF] ? $rec->[CLASSIF] : ''; $rec->[SRV_PLT] = defined $rec->[SRV_PLT] ? $rec->[SRV_PLT] : ''; print STDERR "$rec->[IMP_WG] $rec->[CSC_HAN]\n"; if ( $rec->[IMP_WG] ne '' && $rec->[CSC_HAN] eq '1' ) { print "$rec->[CLASSIF] $rec->[IMP_WG] $rec->[SRV_PLT]\n"; }
--
Tommy Butler, a.k.a. TOMMY

Replies are listed 'Best First'.
Re: Re: split, Use of uninitialized value
by Roger (Parson) on Jan 07, 2004 at 03:42 UTC
    Too much typing, you could do with a one-liner instead. I ++'ed you anyhow because the idea is good. ;-)
    use strict; use Data::Dumper; my $rec = [ undef, 1, '', 2, 0 ]; @$rec = map { defined($_) ? $_ : '' } @$rec; print Dumper($rec); __END__ # ---output --- $VAR1 = [ '', 1, '', 2, '0' ];