Loading ...
Sorry, an error occurred while loading the content.
 

RE: [PBML] Use of uninitialized value error

Expand Messages
  • Charles K. Clarkson
    Denny Malloy wrote: When I tested your script I found more uninitialized errors than you indicated. ... The problem is in both your
    Message 1 of 6 , May 1, 2003
      Denny Malloy <denny.malloy@...> wrote:

      When I tested your script I found more
      uninitialized errors than you indicated.

      : my @code=();
      : while(<IFILE>){
      : chomp;
      : my (@parts)=split /\|/, $_;

      The problem is in both your 'split's.

      Here is an excerpt form perlfunc on split:

      If LIMIT is specified and positive, splits into no more
      than that many fields (though it may split into fewer).

      If LIMIT is unspecified or zero, trailing null fields
      are stripped (which potential users of pop would do
      well to remember).

      If LIMIT is negative, it is treated
      as if an arbitrarily large LIMIT had been specified.

      This means that you should place a -1 as the third
      argument in your split.


      my (@parts) = split /\|/, $_, -1;


      By doing do, you will allow the null fields at the
      end of your file to be filled.
      :
      : if($parts[8] ne "" && $parts[8] ne " "){
      : my $exline = join "|",@parts[0..8,18,19];
      : push @code, $exline;
      : }
      : if($parts[17] ne "" && $parts[17] ne " "){
      : my $srline = join "|",@parts[9..19];
      : push @code, $srline;
      : }
      : }
      :
      : foreach(@code){
      : my (@fl)=split /\|/, $_;

      my @fl = split /\|/, $_, -1;


      HTH,

      Charles K. Clarkson
      --
      Head Bottle Washer,
      Clarkson Energy Homes, Inc.
      Mobile Home Specialists
      254 968-8328
    • Denny Malloy
      my (@parts) = split / |/, $_, -1; Thanks again Charles. I did not realize null fields where not being stripped. I guess I should read Programming Perl
      Message 2 of 6 , May 1, 2003
        my (@parts) = split /\|/, $_, -1;

        Thanks again Charles. I did not realize null fields where not being
        stripped. I guess I should read "Programming Perl" again.
      Your message has been successfully submitted and would be delivered to recipients shortly.