<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">#!/usr/bin/perl
#
# format_o2.pl --&gt; extracts apv data (cf. format_apv.sh)

    while ( defined( $line = &lt;STDIN&gt; ) ) {
        if ( $line =~ "/2003  " ) {
            @fields = split( /\s+/, $line );
            $nfields = @fields;
            if ( $nfields &gt;= 8 ) {
                $time           = @fields[ 3 ];
                $date           = @fields[ 4 ];
                $oxygen_uml     = @fields[ $nfields - 3 ];
                $oxygen_percent = @fields[ $nfields - 2 ];
                $temperature    = @fields[ $nfields - 1 ];
                if ( ( $time           =~ /:/ ) &amp;&amp;
                     ( $date           =~ /\// ) &amp;&amp;
                     ( $oxygen_uml     =~ /\./ ) &amp;&amp;
                     ( $oxygen_percent =~ /\./ ) &amp;&amp;
                     ( $temperature    =~ /\./ ) ) {
                    @datesplit = split( /\//, $date );
                    $month = @datesplit[ 0 ];
                    if ( length( $month ) &lt; 2 ) {
                        $month = "0" . $month;
                    }
                    $day   = @datesplit[ 1 ];
                    if ( length( $day ) &lt; 2 ) {
                        $day = "0" . $day;
                    }
                    $year  = @datesplit[ 2 ];
                    if ( length( $time ) &lt; 8 ) {
                        $time = "0" . $time;
                    }
                    $oxygen_mgl = $oxygen_uml / 32;
                    write;     # see format below
                }
            }
        }
    }

format STDOUT =
@&gt;&gt;&gt;/@&gt;/@&gt; @&gt;&gt;&gt;&gt;&gt;&gt;&gt;  @&gt;&gt;&gt;&gt;&gt; @&gt;&gt;&gt;&gt;&gt; @&gt;&gt;&gt;&gt;&gt;  @#.###
$year, $month, $day, $time, $oxygen_uml, $oxygen_percent, $temperature, $oxygen_mgl
.

</pre></body></html>