Hi everyone I tried to resolve my issue on renaming duplicate data whit this script. But It don't obtain a result. where is my mistake? My aims is to obtain this format Parent same name of its previous ID, this is a imput file

0409 . mR 21213 23782 12787 + . ID=0035v110.18"1" 0409 . ex 21213 23782 . + . Parent=0035v110.18 0409 . mR 22173 24122 9669 - . ID=0035v22.50"1" 0409 . ex 22173 24122 . - . Parent=0035v22.50 0409 . mR 86435 89419 14907 - . ID=0073v110.09"1" 0409 . ex 86435 89419 . - . Parent=0073v110.09 0409 . mR 76753 78963 10984 + . ID=0182v19.88"1" 0409 . ex 76753 78963 . + . Parent=0182v19.88 0409 . mR 40542 45144 20377 - . ID=0210v19.81"1" 0409 . ex 45014 45144 . - . Parent=0210v19.81 0409 . ex 44717 44939 . - . Parent=0210v19.81 0409 . ex 44592 44625 . - . Parent=0210v19.81 0409 . ex 41343 44469 . - . Parent=0210v19.81 0409 . ex 41205 41221 . - . Parent=0210v19.81 0409 . ex 40542 41122 . - . Parent=0210v19.81 0409 . mR 43128 45064 8216 + . ID=0210v20.31_PRE"1" 0409 . ex 43128 44469 . + . Parent=0210v20.31_PRE 0409 . ex 44592 44625 . + . Parent=0210v20.31_PRE 0409 . ex 44717 44939 . + . Parent=0210v20.31_PRE 0409 . ex 45014 45064 . + . Parent=0210v20.31_PRE

<code> use warnings; use feature "say"; use Data::Dumper; my $filename = $ARGV[0]; my $debug = $ARGV1; die "\n\tUSAGE: perl $0 output debug\n\n" unless $ARGV[0]; die "\n\tERROR: Cannot find the file $ARGV[0]\n\n" unless -e $ARGV[0]; open(IN,$filename); my $row = <IN>; my @tabula; my $i = 0; while ($row = <IN>) { $i++; @tabula = "$i) $row"; my $row = split(/\n/,@tabula); my @new_tabula = split(/\t/,$row); #print @tabula; my @field = @tabula; foreach (my @field) { my $id; my $string; if($field2 eq 'mR') { $field8 =~ /\tID(=.+)'$/; $id = $1; $string = "$field[0]\t.\tmR\t$field3\t$field4\t$field5\t$field6\t$field7\tID=$id\n"; } elsif($field2 eq 'ex') { $string = "$field[0]\t.\tex\t$field3\t$field4\t$field5\t$field6\t$field7\tParent=$id\n"; } print $string if $string; } } <code>


In reply to Re^4: rename duplicate data by blacknight
in thread rename duplicate data by blacknight

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.