Ted S. wrote:

> On 11 Aug 2003, Keith Ivey wrote in perl:
> 
> 
>>Ted Schuerzinger <[EMAIL PROTECTED]> wrote:
>>
>>
>>>@line = split /\,/;
>>
>>In the documentation for split() it says "By default, empty 
>>leading fields are preserved, and empty trailing ones are 
>>deleted."  You want to preserve the empty trailing fields, so 
>>you need to use the third argument (and to use the third, you 
>>have to specify the second):
>>
>>   @line = split /,/, $_, -1;
>>
>>Also note that commas are not special in regular expressions, 
>>to there's no need to escape them.
>>
> 
> 
> Sorry, but I'm still getting the uninitialized value warnings.  The 
> offending code is now:
> 
> <snip>
> 
> while (<HITSFILE>) { #open1
> chomp;
> @line = split /,/, $_, -1;

A slightly different approach:

for (@line .. 41) {
        $line[$_] = '';
}

> for $y (1 .. 41)  { #open2 this deals with empty cells
>    unless (defined $line[$y]) { # open3 -- somebody else suggested
>                                 # changing exists to defined.  Both give 
>                                 # the error message.
>    $line[$y] = "";
>    } #close3
>    if ($line[$y] =~/\d/) { #open4
>    $hash{$line[0]}{ratings}[$y]=$line[$y];
>    } #close4
> }#close2                                         
>    for $y (1 .. 41) { #open5
>    if ($hash{$line[0]}{ratings}[$y] =~/\d/) { #open6
>        $hash{$line[0]}{ratingstotal}=$hash{$line[0]}{ratingstotal}+$hash{$
> line[0]}{ratings}[$y];
>        } #close6
> } #close5
> 
> ...
> 
> </snip>
> 
> The warnings still come on the pattern match.



-- 
  ,-/-  __      _  _         $Bill Luebkert    Mailto:[EMAIL PROTECTED]
 (_/   /  )    // //       DBE Collectibles    Mailto:[EMAIL PROTECTED]
  / ) /--<  o // //      Castle of Medieval Myth & Magic http://www.todbe.com/
-/-' /___/_<_</_</_    http://dbecoll.tripod.com/ (My Perl/Lakers stuff)

_______________________________________________
Perl-Win32-Users mailing list
[EMAIL PROTECTED]
To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs

Reply via email to