Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re^5: Football formation

by Loops (Curate)
on Oct 28, 2014 at 06:47 UTC ( [id://1105263]=note: print w/replies, xml ) Need Help??


in reply to Re^4: Football formation
in thread Football formation

Hey eminempark,

As GrandFather said in the first reply of this thread, you haven't shown any code or even a description of what you've tried. I made the quick change you're looking for, but am hoping to see you run the ball the rest of the way into the endzone from here:

use autodie; my (%used, %player); open $player{$_}, '<', "$_.txt" for qw( DR DL DC SW ); open my $formation, '<', 'formation.txt'; for my $position (<$formation>) { chomp $position; while (readline $player{$position}) { my ($name) = split; next if $used{$name}; $used{$name} = 1; last; } print $position, ' ', $_ // "No Player\n"; }

Replies are listed 'Best First'.
Re^6: Football formation
by eminempark (Initiate) on Oct 28, 2014 at 08:12 UTC
    Hi Loops, Sorry if I didn't explain clearly, what I want is the comparison of the second column before comma (,). I have tried the latest code.
    use autodie; my (%used, %player); open $player{$_}, '<', "$_.txt" for qw( DR DL DC SW ); open my $formation, '<', 'formation.txt'; for my $position (<$formation>) { chomp $position; while (readline $player{$position}) { my ($name) = split; next if $used{$name}; $used{$name} = 1; last; } print $position, ' ', $_ // "NoPlayer\n"; }
    but the output is
    SW Varane,114.75 DR Arbeloa,149 DC Ramos,169 DC Pepe,163 DL Marcelo,148.5 SW Pepe,65.2 DR Carvajal,146 DC Varane,153 DC Nacho,134 DL Coentrao,148
    Pepe is still repeating(although the value (163 and 65.2) is different). It supposed to be:
    SW Varane,114.75 DR Arbeloa,149 DC Ramos,169 DC Pepe,163 DL Marcelo,148.5 SW Nacho,60.3 DR Carvajal,146 DC NoPlayer DC NoPlayer DL Coentrao,148
      Hi Loops, sorry that seems like I make u feel frustrating. u are right. my output are
      SW Varane 114.75 DR Arbeloa 149 DC Ramos 169 DC Pepe 163 DL Marcelo 148.5 SW Nacho 60.3 DR Carvajal 146 DC No Player DC No Player DL Coentrao 148
      My second last question, how to sum all the number in the third column? And my last question, how to save the output automatically to a single file based on formation name. Thank you so much, Loops

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1105263]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (2)
As of 2024-04-25 12:47 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found