Hi all,
for some reason, I am having a problem with this.
I have a flat file in the form of:
$userID\t$TempPass\tgroup\n
What I need to do is first, sort everything by userID and the Schwartzian gives output like
User1 temppass1 new
User10 temppass1 new
User2 temppass1 new
User20 temppass1 new
User3 temppass1 new
My userIDs are all that format, User followed by a number.
Then I run the split, and get the same thing, meaning I get the complete line. No split at all so I can pull out the userID
I am sure I am doing something stupid here, my logic may be all wrong....
As always, suggestions greatly appreciated.
Jim
My code:
for some reason, I am having a problem with this.
I have a flat file in the form of:
$userID\t$TempPass\tgroup\n
What I need to do is first, sort everything by userID and the Schwartzian gives output like
User1 temppass1 new
User10 temppass1 new
User2 temppass1 new
User20 temppass1 new
User3 temppass1 new
My userIDs are all that format, User followed by a number.
Then I run the split, and get the same thing, meaning I get the complete line. No split at all so I can pull out the userID
I am sure I am doing something stupid here, my logic may be all wrong....
As always, suggestions greatly appreciated.
Jim
My code:
Code:
open(PASSWORD, "$PASSWORD_FILE") || &Error("Cannot open password file: $PASSWORD_FILE, Error: $!",1);
@PassFile = <PASSWORD>;
close(PASSWORD);
my @sorted = map {$_->[0]}
sort {$a->[1] cmp $b->[1] ||
$a->[2] <=> $b->[2]}
map {m/^([a-z]+)(\d+)$/i; [$_,lc($1),$2]} @PassFile;
$cnt = 0;
foreach (@sorted) {
($name, $pw, $level) = split('\t');
print "<TR><TD ALIGN=\"CENTER\"><INPUT TYPE=radio Name='No' Value='$cnt'> </TD><TD> $name </TD></TR>\n";
$cnt++;
}