Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: Football formation

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


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

Darn. Why not?

Update:

You need a better Perl setup. Don't know what platform you're on but hopefully you can configure your machine to run Perl and install CPAN modules. And most importantly, see error messages without them flashing by. It doesn't make sense to try to do a project like this until you can comfortably run a "hello world" type application.

If you're impatient though, you can just remove the "use autodie ..." line in the script. You wont get decent errors if one of the files can't be opened. But the error would probably just flash by anyway. ;o)

Replies are listed 'Best First'.
Re^4: Football formation
by 2teez (Vicar) on Oct 28, 2014 at 05:51 UTC

    Hi Loop,
    Nice work bro.
    If eminempark uses perl version 5.10.1 or better autodie is in the CORE.

    Simply removing qw(:all) from the line use autodie qw(:all) should do.
    More so, using perldoc autodie the documentation will make the reason for the error message obvious.

    My initial reply to eminempark is here Re^5: Football formation

    If you tell me, I'll forget.
    If you show me, I'll remember.
    if you involve me, I'll understand.
    --- Author unknown to me
Re^4: Football formation
by eminempark (Initiate) on Oct 28, 2014 at 04:45 UTC
    Thank you so much. It works after i remove the "use autodie qw( :all );" But after i update the formation.txt to:
    SW DR DC DC DL SW DR DC DC DL
    and SW.txt:
    Varane 114.75 Pepe 65.2 Nacho 60.3
    The output is:
    SW Varane 114.75#first line of output DR Arbeloa 149#second line of output DC Ramos 169#third line of output DC Pepe 163#fourth line of output DL Marcelo 148.5#fifth line of output SW Pepe 65.2#sixth line of output DR Carvajal 146#seventh line of output DC Varane 153#eighth line of output DC Nacho 134#ninth line of output DL Coentrao 148#tenth line of output
    The sixth line of output is supposed to be Nacho because Pepe is already appear in fourth line. And same goes to 8th line and 9th line. In other words, the contents of the second column are not suppose to repeat or have the same value.

      Hi eminempark,
      Loops scripts works, you need to learn to troubleshoot for yourself at some levels.
      If the error you are getting flashes on the screen, then you can simply make that stay to see which line the error occurs and what error is it. Simply use <> at the end of your script.

      Of course, the error I suppose you are pointing at I think is caused by the usage of qw(:all) in the line that uses autodie. You can take that out and see if it works for you.
      Please, check the documentation for the "autodie" pragma, the reasons were given atleast!

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me
        Hi 2teez, can u help me to solve the repeated line? thank you

      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"; }
        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

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others sharing their wisdom with the Monastery: (5)
As of 2024-04-20 00:23 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found