in reply to Tagging the last elements

Please "use strict", there are a number of errors in your program.

It is probably not necessary to check the format of each line before processing.

It is not clear to me what your first is if statement is supposed to do.

You will need to rethink the logic to produce the desired output unless the numeric values are sorted by name.

You will need additional logic to determine single and end.

Replies are listed 'Best First'.
Re^2: Tagging the last elements
by Anonymous Monk on Jul 28, 2009 at 04:20 UTC
    I think he wanted
    if( defined $5 and defined $6 ) { }