Madhu Reddy wrote:
> Hi,
>   I have following script, basically this will
> ding the duplicate rows in a file...
>
> I am getting following warnings
> Use of uninitialized value at Audit_WTN.pl line 133,
> <FH_IN_FILE> chunk 18.
> Use of uninitialized value at Audit_WTN.pl line 133,
> <FH_IN_FILE> chunk 19.
>
> how to avoid warning at following location....
> 133 if ( $ret >= 1 ) {
>
>
> --------------------------------
> # return 1, if record is duplicate
> #returns 0, if record is not duplicate
> sub find_duplicates ()
> {
> 128        # get the key frim row
> 129 $key = substr($_,8,18);
> 130 $ret = $keys{$key};
>
> 132 #Record is Duplicate
> 133 if ( $ret >= 1 ) {
> 133 $keys{$key}++;
> 134 return 1;
> } else {
> $keys{$key}++;
> return 0; #not a duplicate
> }
> }

Simply

    sub find_duplicates () { $keys{substr($_, 8, 18)}++ }

which will return the number of previous occurrences
of this key.

HTH,

Rob




-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to