Phew, your indentation is overwhelming! Consider these examples to help:

#move this line up (and simplify it): #if(length($materialmapping_file) gt 0 or length($data_folder) gt 0 +) unless (defined $materialmapping_file and defined $data_folder) { print "Usage: $0 <materialmapping_file> <data_folder>\n"; exit; } # Now, everything that follows can be outdented one level.

Similarly:

while( ($filename = readdir(DIR))){ #if($filename =~ /\.xls$/i) { next unless $filename =~ /\.xls$/i; # everything below can be outdented my $parser = Spreadsheet::ParseExcel->new(); my $oBook = $parser->parse($data_folder.$filename); #if (defined $oBook ) { next unless defined $oBook; # everything below can be outdented ...

For your duplication problem, I think this might do:

my %seen; # a new global variable ... # then, whenever you 'createElement' and/or 'setAttribute', first a +ssemble the string: #my $materialmapping_item2 = $materialmapping_table_xml->createElem +ent("item3"); #$materialmapping_item2->setAttribute(decode('cp1252',$pr_cell_name +2->{Val}),$pr2); my $entry = join',', decode('cp1252',$pr_cell_name2->{Val}),$pr2; # and create it if it doesn't already exist: if (!exists $seen{$entry}++){ my $materialmapping_item2 = $materialmapping_table_xml->createEl +ement("item3"); $materialmapping_item2->setAttribute($entry); }

In reply to Re^5: delete duplicated xml lines by hbm
in thread delete duplicated xml lines by cibiena

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.