A few more pointers on your code.
You don't need to check for existence when incrementing the value of a hash key:
if(exists $userhash{$username}) { $userhash{$username}++; } else{ $userhash{$username}=1 ; }
can be written in a single line:
$userhash{$username}++;
It's more readable and maintainable to use Quantifiers (see perlre) in a regular expression than using a string of repeated characters or character classes:
So, [0-9][0-9][0-9][0-9] would have been better if written like [0-9]{4} (in that specific instance, \d{4} would have been even better).
When checking for a value that's being incremented or decremented, it's good defensive programming to check not just the terminating value but also all values beyond that. This will often avoid infinite loops.
So, $bigcounter == 100000 would be better as $bigcounter >= 100000 and similarly for $done != 0.
When using open, it's good practice to separate the mode (e.g. '<' for reading, '>>' for appending, etc.) from the file name. It's also good practice to use a lexically scoped filehandle (e.g. my variable) rather than a global. Also, when using or die ... the parentheses are not required - they are if you use || die ....
Putting that all together
open( INPUTDATAFILE, "< $inputfile" ) or die ...
would become
open my $inputdatafile, '<', $inputfile or die ...
In closing, I will compliment you on your code in general (neatly laid out, meaningful variable names and so on) - don't stop doing that. :-)
-- Ken
In reply to Re: Script Help!
by kcott
in thread Script Help!
by blackice69
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |