I tried that, here's the problem doing it that way:
loop 1 found start_work at 8:00____$start_work = "8:00"
loop 2 found pause_work at 8:10$pause_work = "8:10"
loop 3 found resume_work at 8:20$resume_work = "8:20"
loop 4 found end_work at 8:30______$end_work = "8:30"
total_work_time = ($pause - $start) - ($end - $resume)
total_work_time = 20
But if we make pause and resume "0" on each loop then
loop 1 found start_work at 8:00_____$start = "8:00"
loop 2 found pause_work at 8:10_$pause = "8:10"
loop 3 found resume_work at 8:20$resume = "8:20" and now $pause = "0"
loop 4 found end_work at 8:30______$end = "8:30" and now $resume = "0"
total_work_time = ($pause - $start) - ($end - $resume)
total_work_time = -30 (or whatever)
Don't forget that sometimes there are no pauses or resumes. When that happens the script still has the pause and resume in memory from previous records.