G'day khacee,
Welcome to the monastery.
"I want to get this output but i dont know how to start with array."
Given your question, I'll assume you've already written the code to read your input file. It's better if you post the code to the point where you got stuck: you'll get a better answer that way. This is all explained in: How do I post a question effectively?
Each line appears to consist of a "player" and a "tableid". Use the split function to separate these.
The "tableid" is repeated for multiple "players"; so use that as a hash key pointing to an arrayref of associated "players". Use the push function to add new "players" as you read them from your input.
It's preferable to show code and data within <code>...</code> tags. You've used <p>...</p> tags here; this makes it difficult to see exactly what formatting you wanted for your output. This is explained in: Markup in the Monastery
The following commandline code should serve as a starting point for your program. As already mentioned, without knowing how far you managed get before asking for help, it's difficult to know what help to provide.
$ perl -Mstrict -Mwarnings -E '
my %input;
while (<>) {
push @{$input{$_->[1]}} => $_->[0] for [split];
}
for (sort { $a <=> $b } keys %input) {
say "Tableid: $_";
print q{Player: };
say for @{$input{$_}};
say q{Total: }, scalar @{$input{$_}};
}
'
kapp2cape1111 224
kapp2cape1113 224
kapp2cape1112 224
kapp2cape1111 225
kapp2cape1113 225
kapp2cape1112 225
Tableid: 224
Player: kapp2cape1111
kapp2cape1113
kapp2cape1112
Total: 3
Tableid: 225
Player: kapp2cape1111
kapp2cape1113
kapp2cape1112
Total: 3
If you need further help, please read the guidelines I've linked to, and follow them, before posting again.
|