#!/usr/local/bin/perl -w use File::stat; use strict; use Tie::File; use Env qw(COMPUTERNAME); my($s3) = "d:\\softdev"; my($testdata)= "d:\\softdev\\t.html"; my($graphdata)= "d:\\softdev\\t.html"; my(@testarray); my(@grapharray); chop (my($hostname)= `hostname`); my($COMPUTERNAME) = uc($hostname); my($line); my($newgb); my($grapharray); my($softdev) = "d:\\softdev"; my(@diskspace); my ($new); my($reallynewgb); my($newline); spacecheck(); graphsub(); sub spacecheck { my(@testarray); my $dircheck = "HDDSpace"; my ($meg); die "Cannot perform diskspace check" unless (system("dir $softdev > HDDSpace")==0); tie @testarray, 'Tie::File', "$dircheck"; for(@testarray) { if(/bytes free/) { @testarray = split /\s+/, $_; $testarray[3] =~ s/,//g; $meg = 1024*1024*1024; $newgb = int ($testarray[3]/$meg); print "Diskspace left: " ."$newgb" . "MB\n"; my($reallynewgb) = "$newgb"."GB"; } } undef @testarray; untie @testarray; } sub graphsub { print "$newgb is gb\n"; print "Going to server!\n"; chdir $s3 or die "Cannot change $!\n"; print "going to tie the file\n"; tie @grapharray, 'Tie::File', "$graphdata", or die "Cannot open $graphdata $!\n"; #this opens the file print "$COMPUTERNAME is computername\n putting in $newgb as the new GB\n"; foreach(@grapharray) { if ($_ =~ m/$COMPUTERNAME/) { $line = $_; $newline = $_; print "Line is $line\n"; print "Newline is $newline\n"; my($reallynewgb) = $newgb."GB"; print "line is: $line and $reallynewgb is GB\n"; $newline =~ ($_ =~ (s/(\d|\d\d|\d\d\d)GB/$reallynewgb/)); print "$newline is the newnewline\n"; print "$line is the new line\n"; print "$_ line in \n"; s/$newline/$line/; print "$line\n"; } } untie @grapharray; #finish the array :) }