i wrote this little HL-serverlogparser, to find people using restricted weapons, but when i start it with perl -w script.pl it wont work and exits at line 57 (logfile could not be opened). however if i dont use the "-w" it works just fine....could someone please tell me why ?

#!/usr/local/bin/perl # # AUTOWEAPONBANS N BANLISTCLEANER # V 1.1 # ############################################ use strict; use warnings; use Data::Dumper; use utf8; binmode(STDOUT, ":encoding(UTF8)"); binmode(STDIN, ":encoding(UTF8)"); our (@steam,@name,@scout,@awp,@date,@time); our %players=([@steam],[@name],[@scout],[@awp]); my $datei1 = "banned.cfg"; my $pfad1 = "H:\\perl\\uebungen\\save\\pme\\logparsing\\srcds1\\"; our $file1 = "$pfad1$datei1"; my $datei2 = "banned.cfg"; my $pfad2 = "H:\\perl\\uebungen\\save\\pme\\logparsing\\srcds2\\"; our $file2 = "$pfad2$datei2"; our $infofile = "info.txt"; { package main; &Scan; &Readinfo("$infofile"); &Read("$file1"); &Read("$file2"); &Write("$file1"); &Write("$file2"); &Writeinfo("$infofile"); #print Dumper (%players); } ###################################################################### +############################# # logfile auswerten ###################################################################### +############################# sub Scan { my $file = $ARGV[0]; my ($line); my $steam; my @oldbans; if (!$file) { print STDERR "\n\t KEIN LOGFILE ANGEGEBEN !\n\n"; exit(); } open(LOG, $file) or die ("\n\tPFAD/FILENAME FALSCH ? \n\nLogfile konnt +e nicht geoeffnet werden"); #$file öffnen while(<LOG>) { #$file zeilenweise auslesen chomp(); $line = $_; my $time = substr($line,2,21); #zeit extrahieren if(substr($line,25,1) eq "\"") #auf """ prüfen (pla +yeraction) { $steam = substr($line,index("$line","STEAM_0:",32),(index("$li +ne",">",index("$line","STEAM_0:",32)) -index("$line","STEAM_0:",32))); if(index("$line","with \"scout\"",32) != -1) { # scou +tkills suchen $players{$steam}{$time} = "scout"; $players{$steam}{'info'} = "restricted wea +pon use"; } if(index("$line","with \"awp\"",32) != -1) { # awpk +ills suchen $players{$steam}{$time} = "AWP"; $players{$steam}{'info'} = "restricted wea +pon use"; } } } close(LOG); #print Dumper (%players); } [...more subs...]


In reply to problems opening logfile by m0ve

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.