#!/usr/bin/perl
#
# Copyright (c) 2010 Javier Gutierrez <https://github.com/tap3edit/TAP3-Tap3edit>.
# All rights reserved. This program is free software; you can redistribute
# it and/or modify it under the same terms as Perl itself.
#  
# Creates a TAP3R2 from the hash inside the .TXT file, normally created with tap3edit_display.txt
#  
#  
#  This script creates a file tap3 release 2, giving as input a text file
#  containing a hash (e.g. $VAR1 = {...} ) created by "tap3edit_display.txt", 
#  the output tap3 file will be called as the input file plus the ending ".new"
#  
#  Usage: tap3edit_txt_to_tap3 textfile_with_hash
#  
#  E.g: tap3edit_txt_to_tap3 CDOPER1OPER200001.txt
#  
#  Note: You can change the release of the file by changing 
#        $tap3->release(2) where 2 is the desired release.
#  
#  

use TAP3::Tap3edit;

$filename=shift;

open(FILE, $filename) || die "$!";
$code = do {local $/; <FILE>;};

$VAR1 = eval $code;

$tap3 = TAP3::Tap3edit->new();

$tap3->file_type("TAP");
$tap3->version(3);
$tap3->release(2);

$tap3->structure($VAR1);
$tap3->encode($filename.".new") || die $tap3->error();
