We help IT Professionals succeed at work.

strange simple error

3XLcom
3XLcom asked
on
360 Views
Last Modified: 2013-12-22
there are 3 part of errors that we get

1. the beginning errors
2. in the code you should see if ($reason eq "mbps" ) {
but it still applie else part of if

3. why do we get numeric  error :S

[root@sflow islemler]# perl deneme.pl
Unquoted string "paketlimiti" may clash with future reserved word at deneme.pl line 19.
Unquoted string "trafiklimiti" may clash with future reserved word at deneme.pl line 23.
Name "main::paketlimiti" used only once: possible typo at deneme.pl line 4.
Name "main::trafiklimiti" used only once: possible typo at deneme.pl line 5.
Argument "trafiklimiti" isn't numeric in numeric gt (>) at deneme.pl line 23, <$fh> line 1.
paket limiti asildi
mbps

178.20.230.51 35mbps
1387666838 178.20.230.51 35 mbps
paket limiti asildi
pps

178.20.230.51 3072pps
1387666838 178.20.230.51 3072 pps
paket limiti asildi
mbps

178.20.227.86 11mbps
1387666838 178.20.227.86 11 mbps
paket limiti asildi
pps

79.110.81.134 1536pps
1387666838 79.110.81.134 1536 pps
paket limiti asildi
mbps

178.20.230.51 32mbps
1387666839 178.20.230.51 32 mbps
paket limiti asildi
pps

178.20.230.51 3328pps
1387666839 178.20.230.51 3328 pps

Open in new window










use warnings;

 $paketlimiti = 2500;
 $trafiklimiti = 10;

open(my $fh, '-|', 'sflowtool -4 -p 3601  | /scripts/DoSTargets') or die $!;
while (my $line = <$fh>) {

#print ((split(/ /, $line))[1],"\n");


my $ip  = (split(/ /, $line))[1];
my $size = (split(/ /, $line))[2];
my $reason = (split(/ /, $line))[3];


if ($reason eq "mbps" ) {
        if ($size >  paketlimiti) {
                print "trafik limiti asildi \n";
        }
}else{
        if ($size >  trafiklimiti) {
                print "paket limiti asildi \n";
        }
}

print $reason . "\n";
print $ip." ".$size.$reason;
print $line;
}

close $fh;

Open in new window

Comment
Watch Question

ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
splain
/opt/local/bin/splain: Reading from STDIN
Unquoted string "paketlimiti" may clash with future reserved word at deneme.pl line 19.
Unquoted string "paketlimiti" may clash with future reserved word at deneme.pl
      line 19 (#1)
    (W reserved) You used a bareword that might someday be claimed as a
    reserved word.  It's best to put such a word in quotes, or capitalize it
    somehow, or insert an underbar into it.  You might also declare it as a
    subroutine.

Name "main::paketlimiti" used only once: possible typo at deneme.pl line 4.
Name "main::paketlimiti" used only once: possible typo at deneme.pl line 4 (#2)
    (W once) Typographical errors often show up as unique variable names.
    If you had a good reason for having a unique name, then just mention it
    again somehow to suppress the message.  The our declaration is
    provided for this purpose.
   
    NOTE: This warning detects symbols that have been used only once so $c, @c,
    %c, *c, &c, sub c{}, c(), and c (the filehandle or format) are considered
    the same; if a program uses $c only once but also uses any of the others it
    will not trigger this warning.

Argument "trafiklimiti" isn't numeric in numeric gt (>) at deneme.pl line 23, <$fh> line 1.
Argument "trafiklimiti" isn't numeric in numeric gt (>) at deneme.pl line 23,
      <$fh> line 1 (#3)
    (W numeric) The indicated string was fed as an argument to an operator
    that expected a numeric value instead.  If you're fortunate the message
    will identify which operator was so unfortunate.



Did you mean to say
     if ($size >  $paketlimiti) {

Author

Commented:
yes    if ($size >  $paketlimiti) { this part is not wroking correctly check the output

trafik limiti asildi  8>10
178.20.228.75 8mbps
1387668213 178.20.228.75 8 mbps
trafik limiti asildi  8>10
95.7.67.146 8mbps
1387668214 95.7.67.146 8 mbps
trafik limiti asildi  41>10
185.9.156.83 41mbps





#use strict;
use warnings;

my $paketlimiti = 2500;
my $trafiklimiti = 10;

open(my $fh, '-|', 'sflowtool -4 -p 3601  | /scripts/DoSTargets') or die $!;
while (my $line = <$fh>) {

#print ((split(/ /, $line))[1],"\n");


my $ip  = (split(/ /, $line))[1];
my $size = (split(/ /, $line))[2] + 0;
my $reason = substr((split(/ /, $line))[3],0,-1);


if ($reason eq 'mbps' ) {
        if ($size >  paketlimiti){
                print "trafik limiti asildi  " .$size.">".$trafiklimiti."  \n";
        }else{
                print "trafik limiti asildi  " .$size."<".$trafiklimiti."  \n";
        }
}else{
        if ($size >  trafiklimiti) {
                print "paket limiti asildi \n";
        }
}

print $ip." ".$size.$reason."\n";
print $line;
}

close $fh;

Open in new window

Author

Commented:
that worked but why my variable not acting like a numeric value ;

  
 if ($size >  10){
                print  $size2." trafik limiti asildi  " .$size.">".$trafiklimiti."  \n";
        }else{
                print $size2." trafik limiti asildi  " .$size."<".$trafiklimiti."  \n";
        }

Open in new window

ozo
CERTIFIED EXPERT
Most Valuable Expert 2014
Top Expert 2015

Commented:
If you mean $size, what was its value?
CERTIFIED EXPERT
Commented:
This one is on us!
(Get your first solution completely free - no credit card required)
UNLOCK SOLUTION

Author

Commented:
thanks

Gain unlimited access to on-demand training courses with an Experts Exchange subscription.

Get Access
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Empower Your Career
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE

Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Unlock the solution to this question.
Join our community and discover your potential

Experts Exchange is the only place where you can interact directly with leading experts in the technology field. Become a member today and access the collective knowledge of thousands of technology experts.

*This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

OR

Please enter a first name

Please enter a last name

8+ characters (letters, numbers, and a symbol)

By clicking, you agree to the Terms of Use and Privacy Policy.