package TSV::Reader;

use IO::File;

use strict;

sub new {
	my $package = shift;
	my $file = shift;
	unless (ref $file) {
		$file = IO::File->new($file, "r") or
			die "cannot open file `$file'";
	}
	my $self = bless {
		file => $file,
	}, $package;
}

sub read {
	my $self = shift;
	my $line;
	do {
		$line = $self->{file}->getline;
		defined $line or return undef;
		chomp $line;
	} while $line =~ /^\s*(#|$)/;  # skip comment lines and blank lines

	my @cells = split /\t/, $line, -1;
	# TODO (un)escaping
	return \@cells;
}

1
