Perl script to calculate failure ratio

Hello geeks, Find below a Perl script am writing to calculate some failure rate in our GPRS network, am just starting to use perl for scripting.

#!/usr/bin/perl
#Script written to calculate the following:
#PDP activation failure rate for every 15 minutes interval
#Number of Active PDP Contexts
#Script makes use of expect script statement also.
#Script written  by Gbenga Adigun; email: adigun.gbenga@ercisson.com

use diagnostics;
use strict;
use warnings;

#### First Data Collection
sub pdpsub {
system ("expect /tmp/pdp \$1 > /tmp/\$\$pdp");

##ATTEMPTED ACTIVATIONS____WEB APN
my $attweb1=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 1`;

##COMPLETED ACTIVATIONS____WEB APN
my $compweb1=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 1`;

##ATTEMPTED ACTIVATIONS____BB APN
my $attbb1=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;

##COMPLETED ACTIVATIONS____BB APN
my $compbb1=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;
system ("rm /tmp/\$\$pdp");

sleep 20;

##### Second Data Collection with the Number of Active PDP contexts
system ("expect /tmp/pdp \$1 > /tmp/\$\$pdp");
my $pdp=`cat /tmp/\$\$pdp | grep "pdp-active:" | head -n 1 | awk '{print \$2}'`;

##ATTEMPTED ACTIVATIONS____WEB APN
my $attweb2=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 1`;

##COMPLETED ACTIVATIONS____WEB APN
my $compweb2=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 1`;

##ATTEMPTED ACTIVATIONS____BB APN
my $attbb2=`cat /tmp/\$\$pdp | grep "pdp-attempted-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;

##COMPLETED ACTIVATIONS____BB APN
my $compbb2=`cat /tmp/\$\$pdp | grep "pdp-completed-activation:" | awk '{ print \$2 }' | head -n 2 | head -n 1`;

####CALCULATION PART
my $attweb3 = $attweb2 - $attweb1;
my $compweb3 = $compweb2 - $compweb1;
my $attbb3 = $attbb2 - $attbb1;
my $compbb3 = $compbb2 - $compbb1;
my $failpdpweb = (($attweb3 - $compweb3)/$attweb3)*100;
my $failpdpbb = (($attbb3 - $compbb3)/$attbb3)*100;
print $failpdpweb;
print $failpdpbb;
print $pdp;
system ("rm /tmp/\$\$pdp");
}

&pdpsub 192.168.12.177;

But perl keeps giving the following error:

String found where operator expected at test.pl line 60, near "&pdpsub
        "192.168.12.177"" (#1)

syntax error at test.pl line 60, near "&pdpsub "192.168.12.177""

Uncaught exception from user code:
        syntax error at test.pl line 60, near "&pdpsub "192.168.12.177""
Execution of test.pl aborted due to compilation errors.

I will appreciate any feedback, i tried using bash scripting but the calculation part seems to be giving more problems.

Thanks!

If you show us your input and expected output, it would be better to help you..