I tried what you suggested but the argument for the loop was read from a file like so

#!/usr/bin/perl $log = "/home/tsec/prototype/logs/extractedlogs/cowrieresult.log"; open(DATA, $log) or die "Can't open '$log': $!"; sub tester(){ while(<DATA>){ if (/New connection: ([\d\.]+):(\d+)/){ ($ip,$port) = ($1,$2); next; } chomp; if (/login attempt\s+\[(.*)\]\s+(\w+)$/){ ($user_pass,$status) = ($1,$2); $HONEY{$ip}{$port}{$status}{$user_pass} +=1; print "DEBUG: Add ip=$ip:$port $status $user_pass\n"; } } for my $ip (keys %HONEY){ for my $port (keys %{$HONEY{$ip}}){ for my $user (keys %{$HONEY{$ip}{$port}}){ for my $status (keys %{$HONEY{$ip}{$port}}){ for my $user_pass (keys %{$HONEY{$ip}{ +$port}{$status}}){ $freq = $HONEY{$ip}{$port}{$st +atus}{$user_pass}; push(@DATA, "$port,$status,$fr +eq") ; } } } } } for my $data (sort @DATA){ print $data . "\n"; } }

Unfortunately nothing was outputted on the screen. Also if I use stict and warnings it says that variables requires explicit package name and other errors as well as shown below

Variable "@DATA" is not imported at ./test2.prg line 31. Variable "@DATA" is not imported at ./test2.prg line 38. Global symbol "$log" requires explicit package name at ./test2.prg lin +e 6. Global symbol "$log" requires explicit package name at ./test2.prg lin +e 8. Global symbol "$log" requires explicit package name at ./test2.prg lin +e 8. Global symbol "$ip" requires explicit package name at ./test2.prg line + 14. Global symbol "$port" requires explicit package name at ./test2.prg li +ne 14. Global symbol "$user_pass" requires explicit package name at ./test2.p +rg line 19. Global symbol "$status" requires explicit package name at ./test2.prg +line 19. Global symbol "%HONEY" requires explicit package name at ./test2.prg l +ine 20. Global symbol "$ip" requires explicit package name at ./test2.prg line + 20. Global symbol "$port" requires explicit package name at ./test2.prg li +ne 20. Global symbol "$status" requires explicit package name at ./test2.prg +line 20. Global symbol "$user_pass" requires explicit package name at ./test2.p +rg line 20. Global symbol "$ip" requires explicit package name at ./test2.prg line + 21. Global symbol "$port" requires explicit package name at ./test2.prg li +ne 21. Global symbol "$status" requires explicit package name at ./test2.prg +line 21. Global symbol "$user_pass" requires explicit package name at ./test2.p +rg line 21. Global symbol "%HONEY" requires explicit package name at ./test2.prg l +ine 25. Global symbol "%HONEY" requires explicit package name at ./test2.prg l +ine 26. Global symbol "%HONEY" requires explicit package name at ./test2.prg l +ine 27. Global symbol "%HONEY" requires explicit package name at ./test2.prg l +ine 28. Global symbol "%HONEY" requires explicit package name at ./test2.prg l +ine 29. Global symbol "$freq" requires explicit package name at ./test2.prg li +ne 30. Global symbol "%HONEY" requires explicit package name at ./test2.prg l +ine 30. Global symbol "@DATA" requires explicit package name at ./test2.prg li +ne 31. Global symbol "$freq" requires explicit package name at ./test2.prg li +ne 31. Global symbol "@DATA" requires explicit package name at ./test2.prg li +ne 38. Execution of ./test2.prg aborted due to compilation errors.

In reply to Re^2: Increment frequency of attempts based on IP and login details combination by firepro20
in thread Increment frequency of attempts based on IP and login details combination by firepro20

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.