in reply to Changing a varaibale name within the program?
If I was doing this I might attack it as such.. (not tested)...
In cases where you are tempted to name things foo1, foo2, foo3... you should take a second look at using an array, because it will likely serve you well. In this case you already were, but then you went awry and started making pointless variables.my @user_files = <longfilename>; unshift(@user_files, 'blank'); # skipping to the $ufile line # Make sure $choice is numeric and # within the range in user_files if ( ($choice =~ /^\d+$/) && ($choice > 0) && ($choice <= scalar(@user_files)) ) { file_mod($user_files[$choice], $mail_flag); } else { # Error condition, choice outside of range }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: Changing a varaibale name within the program?
by Hofmator (Curate) on Jun 27, 2001 at 15:43 UTC | |
|
Re: Re: Changing a varaibale name within the program?
by Dalin (Sexton) on Jun 26, 2001 at 23:43 UTC | |
by chromatic (Archbishop) on Jun 27, 2001 at 00:04 UTC | |
by Dalin (Sexton) on Jun 27, 2001 at 00:43 UTC |