"L P" <[EMAIL PROTECTED]> writes:

> I need to read lines 26 and 27 to check to see if there are two things
> present
> 1.    That from col 11-18 “Running ” is there and 58-82 is NULL
> 
> I am using the seek function to do this.  Is that correct?  From my
> understand the only positions you can set are.
> 0.    Beginning
> 1.    Current
> 2.    End
> If that is the case it is not.

Your understanding of seek is right.  It doesn't feel like the right
tool for this problem.  Seek is byte-oriented, but your problem is
line-oriented.  You suggested to look at lines 26 & 27.  Let me
suggest another (more perlish and more robust) approach.  Key off some
part of the message content that's not going to change, then trigger
on some other information to get the right lines.

#  TK_PID       TK_DISP_RUNSTATE   TK_START_TIME             TK_END_TIME
#  ----------   ------------------------------
#  ---------------------------------  -------------------
#  334                  Running                             12/13/2001 08:36:23
#  88                   Running                                 12/13/2001 08:35:25
# 
while(<WORKFLOW>) {
/^TK_PID/ .. $ and do { # In the table data?
    if (/^\d+) {        # Is it a TK_PID data line?
        my ($pid, $run_state, $start, $end) = unpack("whatever", $_);
        warn "problem" unless $run_state eq "Running && $end eq "";
}

This uses a little-known but handy flip-flop (..).  When .. is used in
a boolean context (as it is here), it turns on when its LHS matches
and off when its RHS matches.  In your case, it's on (true) from the
time you see "TK_PID" at the beginning of a line (see the RE) until
the last line ($ is shorthand for the last line).  You've now keyed on
the "data" part of the message, let's make sure we grab the right
lines.  Those lines are the ones beginning with one or more digit(s).
If that's the case, use unpack to pull apart the fixed witdth line.  I
don't remember the syntax -- look it up.  The pieces go into scalars
that can be used, and that's what's done to print the warning unless
some condition is satisfied.

The benefits I see here are that the legal department can insert a
larger clausee (perhaps they're "True Americans" and want to make sure
that no "Damn Non-Americans" use the software to topple buildings, and
want to make sure that their App's covered).  If you counted lines,
your software would stop working.  Now, it will only stop working if
the "data" part or headers are changed -- less likely, and more
obvious when it does happen 6 months from the last time you laid eyes
on this.  Style issue -- add a sample of your data above the code as a
comment.  It helps you write it *now* and for others to read it
*later*.

-- 
Michael R. Wolf
    All mammals learn by playing!
       [EMAIL PROTECTED]


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to