Why the fixation on speed? Worry about how long it takes to implement. Only worry about execution time if it turns out to be a problem later.
For your second question, you can slurp the entire file into an array and then search the array, which should speed up the IO (which is easily the slowest part). Example:
open(FH, '<', 'somefile.txt') or die $!; my @in = <FH>; close(FH); my $want_username = 'myusername'; my $hit; while( (! $hit) && (my $entry = shift @in) ) { my $in_user = (split /:/, $entry)[1]; $hit = ($in_user eq $username); }
Update: Typo in variable name.
----
I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
-- Schemer
Note: All code is untested, unless otherwise stated
In reply to Re: Quick User Existance Check?
by hardburn
in thread Quick User Existance Check?
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |