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

RE: [PBML] Use of uninitialized value error

Expand Messages
  • Denny Malloy
    On Thu, 1 May 2003 10:15:02 -0400, Denny Malloy wrote ... well, you didn t declare @digest ... I did at the top of my code. I didn t post that part. Sorry!
    Message 1 of 6 , May 1, 2003
    • 0 Attachment
      On Thu, 1 May 2003 10:15:02 -0400, Denny Malloy wrote
      > Hi,
      >
      > I keep getting an uninitialized error and I do not know how to fix
      > it.

      well, you didn't declare @digest ...

      I did at the top of my code. I didn't post that part. Sorry!



      Unsubscribing info is here:
      http://help.yahoo.com/help/us/groups/groups-32.html

      Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
    • Jenda Krynicky
      From: Jonathan Dunn ... the uninitialized error is NOT related to variable declaration at all! Try #!perl -w my $foo; print
      Message 2 of 6 , May 1, 2003
      • 0 Attachment
        From: "Jonathan Dunn" <jon@...>
        > On Thu, 1 May 2003 10:15:02 -0400, Denny Malloy wrote
        > > Hi,
        > >
        > > I keep getting an uninitialized error and I do not know how to fix
        > > it.
        >
        > well, you didn't declare @digest ...

        the uninitialized error is NOT related to variable declaration at
        all! Try

        #!perl -w
        my $foo;
        print "foo=$foo\n";

        Is $foo declared? Yes!
        Is $foo initialized? No!

        All the warning says is that the value of the variable was undef.
        Nothing more. This might happen because you forgot to assign a value
        to the variable, because you undef()ed the variable or because the
        function whose return value you assigned to the variable returned
        undef:

        #!perl -w
        my $foo = 5;
        print "foo=$foo\n";
        undef $foo;
        print "foo=$foo\n";


        IMHO this particular warning is pretty useless. And very often
        annoying.

        Jenda
        ===== Jenda@... === http://Jenda.Krynicky.cz =====
        When it comes to wine, women and song, wizards are allowed
        to get drunk and croon as much as they like.
        -- Terry Pratchett in Sourcery
      • 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 3 of 6 , May 1, 2003
        • 0 Attachment
          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 4 of 6 , May 1, 2003
          • 0 Attachment
            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.