Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re^3: rename duplicate data

by ww (Bishop)
on Jun 22, 2012 at 16:09 UTC ( #977870=note: print w/ replies, xml ) Need Help??


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.


Comment on Re^3: rename duplicate data
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://977870]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (13)
As of 2014-10-21 10:35 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (100 votes), past polls