Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

getting the difference in the number lines

Status
Not open for further replies.

Natalie30

Programmer
Feb 5, 2003
12
0
0
US
I need help seeing the difference in the number lines, in this script i writing back the previous number of lines. I need a subtraction statement. thanks, N


$data_file = "/root/bin/load.data2";
open(FILE,&quot;<$data_file&quot;) or die &quot;Cant open $data_file2: $!\n&quot;;
@log = <FILE>;
$last_element='&quot;0&quot;';
foreach(@log){
chomp;
s/\015//;
my@list = split',';
print&quot;$_,$last_element\n&quot;;
$last_element = $list[$#list];
}
close (FILE);


<output>
&quot;Mon Feb 10 11:28:00 2003&quot;,&quot;17.42&quot;,&quot;134&quot;,&quot;1443&quot;,&quot;69978&quot;,&quot;69041&quot;
&quot;Mon Feb 10 11:29:00 2003&quot;,&quot;19.98&quot;,&quot;118&quot;,&quot;1288&quot;,&quot;70729&quot;,&quot;69978&quot;
&quot;Mon Feb 10 11:30:00 2003&quot;,&quot;20.26&quot;,&quot;195&quot;,&quot;1328&quot;,&quot;71443&quot;,&quot;70729&quot;
 
Natalie30,
do you really want your script to give you

&quot;Mon Feb 10 11:28:00 2003&quot;,&quot;17.42&quot;,&quot;134&quot;,&quot;1443&quot;,&quot;69978&quot;,&quot;69041&quot;, &quot;937&quot;(the difference between 69978 and 69041) and so on?
Perhaps it will be clearer if you list a small
portion of the input file and be a bit clearer in what you
want the scipt to do

svar

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top