http://www.perlmonks.org?node_id=977870


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

Continuing with the issues and advice:

Please surround your code and data listings with <c> (at the beginning) and </c> (at the end). It makes your nodes much easier to read, and thus, more likely to draw help.

Your indentation style may have been different, but surely you saw that your code didn't look 'right' (for some value of 'right' meaning 'easy to read'):

#!/usr/bin/perl; use strict; use warnings; 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 $ids; while($filename){ chomp; if(/(ID=.+)$/){ if(++$ids{$1} > 1){ say $_, $ids{$1}; next; } } say; } print say;

The say in Line 18 probably doesn't do what you intended; print say; in Line 20 is meaningless.

say is "Just like "print", but implicitly appends a newline" to quote the 5.014 doc. To use it, either include use 5.010 (or higher; 5.016 is current) as monsoon suggested or use feature qw(switch say); (where feature is a (relatively new) pragma to enable new features that are not available without specifically enabling them).

Other issues start with the unnecessary (but harmless) semi-colon at the end of the hashbang (or, in order of severity, your incorrect attempt to invoke debug mode, as noted by monsoon.