Data-Table-Gherkin

 view release on metacpan or  search on metacpan

lib/Data/Table/Gherkin.pm  view on Meta::CPAN

sub _is_unique ( $ );

sub parse {
  my $options = ( ref $_[ -1 ] eq 'HASH' ) ? pop : {};
  my ( $class, $table ) = @_;

  my $self = bless { no_columns => 0, no_rows => 0, rows => [] }, $class;

  # By default split() strips trailing empty fields. This is a perfect
  # behaviour in the paragraph mode use case
  my @rows = split /\n/, openhandle $table ? do { local $/ = ''; scalar <$table> } : $table;

  # Optional header row parsing
  my $column_headers;
  if ( delete $options->{ has_header } ) {
    return unless defined( $column_headers = $self->_parse_row( shift @rows ) );
    _is_unique $column_headers
      or _carpf( 'Column headers are not unique (row number %d)', $self->no_rows ), return
  }

  # Data row parsing



( run in 0.813 second using v1.01-cache-2.11-cpan-5c0b1e786e0 )