App-Table2YAML

 view release on metacpan or  search on metacpan

lib/App/Table2YAML/Loader/AsciiTable.pm  view on Meta::CPAN

use common::sense;
use charnames q(:full);
use English qw[-no_match_vars];
use Moo::Role;

our $VERSION = '0.003'; # VERSION

sub load_asciitable {
    my $self = shift;

    local $INPUT_RECORD_SEPARATOR = $self->record_separator();
    my $ref = ref $self->input() || q();
    my $ascii_fh
        = $ref eq q(GLOB)
        ? $self->input()
        : IO::File->new( $self->input(), q(r) );

    my $sep = qq(\N{VERTICAL LINE});
    my @asciitable;
    while ( my $record = readline $ascii_fh ) {
        chomp $record;

lib/App/Table2YAML/Loader/FixedWidth.pm  view on Meta::CPAN

    my $self = shift;

    my @fixedwidth;

    my @template = @{ $self->field_offset() };
    foreach my $offset (@template) {
        substr $offset, 0, 0, q(A);
    }
    my $template = join q(), @template;

    local $INPUT_RECORD_SEPARATOR = $self->record_separator();
    my $ref = ref $self->input() || q();
    my $fw_fh
        = $ref eq q(GLOB)
        ? $self->input()
        : IO::File->new( $self->input(), q(r) );
    while ( my $record = readline $fw_fh ) {
        chomp $record;
        my @row = unpack $template, $record;
        push @fixedwidth, [@row];
    }



( run in 0.292 second using v1.01-cache-2.11-cpan-c6e0e5ac2a7 )