[mrtg] Perl RegEx question

Scott S. Heath SHeath at udi.com
Wed Apr 16 23:34:01 CEST 2008


I've got the following code (it's part of a larger script to parse
Exchange 2007 info into MRTG) and I can't seem to get it to output the
right number.

The File it's opening/reading contains: "ReplayQueueLength
: 50"
I expect it to output "50" as the result, but it keeps outputting "5"
and dropping the last 0. When I copy this line into the code and skip
reading it from the file it works fine, when I print the line after
reading it from a file it also works fine.

>From this it looks like it's reading the file fine, and the regex is
correct. What would be causing that last 0 getting dropped off?

===========Begin Code=============


$FileName = "NOAttorney-replayqueuelength.txt";
open(my $REPLAYQUEUEFILE, $FileName) or die "can't open '$FileName'
$!";;
my $ReplayqueueFile = <$REPLAYQUEUEFILE>;
if($ReplayqueueFile =~ m/(\d+)/){
        print $1;
        $replayQueueLength = $1;
}
print "\n";

===========End Code===============

Any ideas?

Thanks,
Scott



More information about the mrtg mailing list