in reply to Re: Changing a varaibale name within the program?
in thread Changing a varaibale name within the program?

I'm a little confused on the "blank" in the unshift statement? Should I try "blank" or should this be an actual var of some kind. Sorry for all of the newbie questions. Bradley
Where ever there is confusion to be had... I'll be there.

Replies are listed 'Best First'.
Re: Re: Re: Changing a varaibale name within the program?
by chromatic (Archbishop) on Jun 27, 2001 at 00:04 UTC
    Perl arrays start with an index of 0. That is, the first element of @items can be accessed as $items[0]. Adding a blank element to the start of the array means that if the user requests file 1, you can just say @user_files[$choice] instead of $user_files[$choice - 1].

    I'd rather do $choice - 1, but either way, add a comment to the code noting your choice and why you're doing it:

    # @user_files starts at zero, user choice starts at 1 process($user_files[$choice - 1]);
    That'll make life much easier for the maintainer.
      Thanks guys. I'll try this out as soon as I can. Pesky job gets in the way of coding. I'll let you know how it goes. Thanks again. Bradley
      Where ever there is confusion to be had... I'll be there.