I have done a script, but it is based on shell script, and i want to convert it to perl. I am very new to perl.

#!/bin/bash
echo $b
echo $fileday
echo $datatype
# Count Daily Total History:
for i in $datatype
do
gzcat $addToPath/PM.$b.$fileday.*.xml.gz |grep $i >> $addToPath/$i.log
done

# Summation Daily Total Counts:
for i in $datatype
do
total=0
number=0
filename=$addToPath/$i.log
while read line
do
number=` echo $line | cut -d '>' -f2 | cut -d '<' -f1 `
let total+=number
done < $filename
echo " the $i total sum = $total" >> $addToPath/$result_file
cat $addToPath/$result_file
done