Scroll to navigation

Vnlog::Parser(3pm) vnlog Vnlog::Parser(3pm)

NAME

Vnlog::Parser - Simple library to parse vnlog data

SYNOPSIS

 use Vnlog::Parser;
 my $parser = Vnlog::Parser->new();
 while (<DATA>)
 {
     if( !$parser->parse($_) )
     {
         die "Error parsing vnlog line '$_': " . $parser->error();
     }
     my $d = $parser->getValuesHash();
     next unless %$d;
     say "$d->{time}: $d->{height}";
 }

DESCRIPTION

This is a simple perl script to parse vnlog input and make the incoming key/values available. The example above is representative of normal use. API functions are

  • new()

    Creates new Vnlog::Parser object. Takes no arguments.

  • parse(line)

    Method to call for each input line. On error, a false value is returned.

  • error()

    If an error occurred, returns a string that describes the error.

  • getKeys()

    Returns a list-ref containing the current column labels or undef if this hasn't been parsed yet.

  • getValues()

    Returns a list-ref containing the values for the current line or undef if there aren't any. This isn't an error necessarily because this line could have been a comment. Empty fields are '-' in the vnlog and undef in the values returned here.

  • getValuesHash()

    Returns a hash-ref containing the key-value mapping for the current line or undef if there's no data in this line. This isn't an error necessarily because this line could have been a comment. Empty fields are '-' in the vnlog and undef in the values returned here.

REPOSITORY

<https://github.com/dkogan/vnlog>

AUTHOR

Dima Kogan, "<dima@secretsauce.net>"

LICENSE AND COPYRIGHT

Copyright 2016 California Institute of Technology.

This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.

2024-02-04