use Text::FixedWidth; my @fields = ( { field => name, from => 1, to => 5 }, { field => email, from => 8, to => 25 }, ); my $fw = Text::FixedWidth->new( fields => \@fields, ); $data_ref = $fw->parsefile('data.txt'); #### $data_ref = [ { name => 'Bob', email => 'bob@email.com' }, { name => 'Sam', email => 'sam@mail.com' }, ];