in reply to Use of uninitialized value

Thanks for your help so far.
The offending line is something like this
$item = "$code[0]" . "."."$code[1]" . ".". "$code[2]";
Any comments appreciated

Replies are listed 'Best First'.
Re^2: Use of uninitialized value
by Fletch (Bishop) on Feb 28, 2007 at 16:33 UTC

    Erm . . . ouch.

    • The quotes around "$code[0]" are superfluous, to start
    • You could have just written it as "$code[0].$code[1].$code[2]" in one swell foop
    • Of course that locks you in to a fixed number of elements; if you want to join an arbitrary number of items in @code then just use join: $item = join( ".", @code );
      If want a specific subset of elements, then you can use a slice:
      my $item = join( ".", @code[0..2] ); my $not_item = join( ".", @code[9,7,0,3] );


      TGI says moo

      Fletch, agreed that it's untidy as it is, but  $code[0].$code[1].$code[2] ne join( ".", @code ).

      Best,

      andye

      Update: Anno is right, I did overlook a pair of quotes. Ignore me. :)

        You overlooked a pair of quotes. Assuming that @code contains three elements, "$code[0].$code[1].$code[2]" is indeed the same as join '.', @code.

        Anno

Re^2: Use of uninitialized value
by andye (Curate) on Feb 28, 2007 at 16:27 UTC
    One or more of ($code[0], $code[1], $code[2]) has nothing in it.

    Best,

    andye