archieg has asked for the wisdom of the Perl Monks concerning the following question:

The below is not working. Trying to check the duplicates in the lookup file before entering the user parameters
if(check_dup_rec("$APPHOME/DATA/lookup/lookup_file.txt","$actv_id,$ite +ration_id,$wave_id")) { print "\nTo ABORT press CTRL+C or Press ENTER key to Continue.. +."; chomp($key = <STDIN>); } check_dup_rec("$APPHOME/DATA/lookup/lookup_file.txt","$actv_id,$iter +ation_id,$wave_id");

Replies are listed 'Best First'.
Re: lookup/duplicate check in perl
by NetWallah (Canon) on Sep 14, 2015 at 02:52 UTC
    Welcome to the monastery!

    You are asking a question about a subroutine "check_dup_rec", and have not shows us what it contains.

    Without that , we will be unable to assist.

    Please post code, using <code/> tags, as AnomalousMonk has suggested.

            Software efficiency halves every 18 months, thus compensating for Moore's Law.

Re: lookup/duplicate check in perl
by Athanasius (Archbishop) on Sep 14, 2015 at 06:24 UTC

    Hello archieg, and welcome to the Monastery!

    Whatever sub check_dup_rec does, what is the point of calling it twice with the same arguments? If the first call returns a true value, the user is given the choice of either aborting the script or continuing. But neither of the two subroutine arguments is changed, so why call the same subroutine again immediately afterwards?

    The second argument also looks suspicious to me: "$actv_id,$iteration_id,$wave_id". This creates a single string from the contents of 3 variables, separated by commas. I suppose that may be what you want, but it would seem more natural to pass those variables in as 3 separate arguments:

    if (check_dup_rec("$APPHOME/DATA/lookup/lookup_file.txt", $actv_id, $i +teration_id, $wave_id))

    Also: do you use the contents of $key after the if block ends? If not, why chomp it? For that matter, why assign it at all?

    if (...) { print "\nTo ABORT press CTRL+C or Press ENTER key to Continue..."; <STDIN>; }

    P.S. Your script is running under use strict; use warnings;, isn’t it? ;-)

    Hope that helps,

    Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,

Re: lookup/duplicate check in perl
by AnomalousMonk (Archbishop) on Sep 13, 2015 at 22:57 UTC