in reply to Re^3: rename duplicate data
in thread rename duplicate data

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>

Replies are listed 'Best First'.
Re^5: rename duplicate data
by Athanasius (Archbishop) on Jun 26, 2012 at 12:00 UTC

    Hi blacknight,

    I see from your post’s HTML source that you have made an effort at correct formatting. Unfortunately, you made three mistakes:

    • The input file needs to be formatted as code. Replace the outer <p> and </p> with <code> and </code>.
    • For your script, you have written &lt;code> where you need to use a literal < character: <code>.
    • Your closing </code> tag is missing the slash ‘/’ character.

    Please make these changes and re-submit using the ‘update’ button. This will make it much easier for the monks to help you.

    Regards,

    Athanasius <°(((><contra mundum