ddrew78 has asked for the wisdom of the Perl Monks concerning the following question:
Here is my problem. The current code I have isCS CS
Running the above file thru this hash will returnopen(PBXNUM1, ">pbxnum1"); open(MYINPUTFILE, "pbxnum"); my %hash; while (<MYINPUTFILE>) { chomp; $hash {$_} ++; print PBXNUM1 "$_$hash{$_}\n"; }
While this is great when generating new files, the problem is that CS1 & CS2 already exist, and I need it to begin at CS3. There is a variable, $pbxex, that the user will input to show the number of existing occurances, but no matter how I reference that variable (see below), the hash always begins at "1". Any ideas how I can modify this code to work properly? As usual, I appreciate any and all suggestions.CS1 CS2
open(PBXNUM1, ">pbxnum1"); open(MYINPUTFILE, "pbxnum"); my $hash = $pbxex; while (<MYINPUTFILE>) { chomp; $hash {$_} ++; print PBXNUM1 "$_$hash{$_}\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Hash not working as intended
by jethro (Monsignor) on Feb 28, 2011 at 15:26 UTC | |
by ddrew78 (Beadle) on Feb 28, 2011 at 15:40 UTC | |
|
Re: Hash not working as intended
by Eliya (Vicar) on Feb 28, 2011 at 15:24 UTC | |
|
Re: Hash not working as intended
by toolic (Bishop) on Feb 28, 2011 at 15:30 UTC | |
|
Re: Hash not working as intended
by runrig (Abbot) on Feb 28, 2011 at 15:32 UTC | |
|
Re: Hash not working as intended
by AnomalousMonk (Archbishop) on Feb 28, 2011 at 19:57 UTC |