hi gurus, I have problem in type casting, here is the problem..
I get two values after greping and spliting a file( the values are some thing like this "367" and "522>\n") fetching of those two values from file would be in loop .. now for each interation i have to compare these values and return the maximum (i..e present values with the values of previous interation) i tried comparing them by converting into integers (ii.e int("367")) i am not able to do it .... I am getting the following error INDEX INITIALLY : "421" Argument ""188"" isn't numeric in int at E:\XYZ\ZBC\tt.pl line 50. INDEX SUB : "188" INDEX MAIN : "188" SEARCH INITIALLY : "141"> Argument ""312">\n" isn't numeric in int at E:\XYZ\ZBC\tt.pl line 59. SEARCH SUB : "312"> SEARCH MAIN : "312" Here is my code : #!/usr/bin/perl -w use strict; use Switch; my $i=1; my $INDEXMAX=""; my $SEARCHMAX=""; my @MAXISCNO=""; my @MAXSSCNO=""; my %var=""; my $maxiscno=""; my $maxsscno=""; sub MAX_ELAPSE{ my $count=$_[1];my $log=$_[2]; my $logdir=$log . "logs"; my $logfile=$log . "$count" . ".log"; my $file="E:/XYZ/ZBC/Logs/$logdir/$logfile"; my $indexmaxvar=""; my $searchmaxvar=""; open LOGFILE,"$file"; my @grepNames=grep(/(TimeTaken)/, <LOGFILE>); close(LOGFILE); foreach my $s (@grepNames) { my @words=split(/ /, $s); foreach my $w (@words) { if ($w=~m/(docsAdded|msElapsedTime)/) { %var=split(/=/,$w); } } } switch ($log) { case "index" { $indexmaxvar=$_[0]; print "INDEX INITIALLY : $indexmaxvar\n"; foreach my $arr (keys (%var)) { if (int($indexmaxvar) <= int($var{$arr})) { $indexmaxvar=$var{$arr};$maxiscno=$count; print"INDEX SUB : $indexmaxvar\n";} return ($indexmaxvar,$maxiscno); } } case "search" { $searchmaxvar=$_[0]; print "SEARCH INITIALLY : $searchmaxvar\n"; foreach my $arr (keys (%var)) {if (int($searchmaxvar) <= int($var{$arr})) { $searchmaxvar=$var{$arr};$maxsscno=$count; print"SEARCH SUB : $searchmaxvar\n";} return ($searchmaxvar,$maxsscno); } } } } while ($i<=26) { print "________________________________________SCENARIO NUMBER $i START_________________________________\n"; ($INDEXMAX,$MAXISCNO)=MAX_ELAPSE($INDEXMAX,$i,"data"); print "INDEX MAIN : $INDEXMAX\n"; ($SEARCHMAX,$MAXSSCNO)=MAX_ELAPSE($SEARCHMAX,$i,"result"); print "SEARCH MAIN : $SEARCHMAX\n"; print "________________________________________SCENARIO NUMBER $i END________________________________\n"; $i = $i +1; } the data file content would be some thing like this (and this content is same for all files, only the Time Taken attribute changes .. <Result TimeTaken="250" > <result="E::\XYZ\ABC"> </Result> the result log would be some thing like this (and this content is same for all files, only the Time Taken attribute changes .. ) <Result TimeTaken="297"> Some body please Help me with this ..... Iam stucked up with it. thanks in advance, rohit