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

Hi Monks, Here is my piece of code--
main(); sub main { $result = GetOptions ("LogDir=s" => \$LogDir, "Summary" => \$Summary, "Indiviual=s" => \$Individual , "Diagnostics=s" => \$Diagnostics, "Prefix=s" => \$Prefix, "All" => \$All, "help" => \$help); usage_help() if($help); usage_help() unless($Prefix); usgage_help() unless($LogDir); if($LogDir) { die "Log dir '$LogDir' doesn't exist" unless -d $LogDir; } $glob_path = "$LogDir/${prefix}*"; @log_paths = glob $glob_path or die "No files found in '$glob_path'"; printf "log files = \n"; print @log_paths; printf "\n"; if($Summary) { process_summaryreport (); } if($Individual) { if($Individual == "ArcotID") { ArcotID_Authentication(@log_paths); } } }
I am calling the script as--
C:\Perl Script>perl summaryreport_latest_working.pl --LogDir=. --Prefi +x=arcotweb --Individual=ArcotID
It does not show me any output. I think the problem lies here.
if($Individual) { if($Individual == "ArcotID") { ArcotID_Authentication(@log_paths); } }
How to modify this part to get the correct output. Please suggest me something to get rid of this problem. Thanks NT

Replies are listed 'Best First'.
Re: calling problem in script
by Corion (Patriarch) on Jun 30, 2009 at 14:27 UTC
    I think the problem lies here.

    Why do you think that?

    Perl would tell you where the problem lies if you used warnings and diagnostics.

    Most likely, you want to (re)read perlop

Re: calling problem in script
by moritz (Cardinal) on Jun 30, 2009 at 14:26 UTC
    if($Individual == "ArcotID")

    == compares numbers, eq compares strings. See also perlop.

Re: calling problem in script
by davorg (Chancellor) on Jun 30, 2009 at 14:26 UTC
    if($Individual == "ArcotID")

    Looks like you're using the wrong comparison operator. '==' is for comparing numerical values. To compare strings use 'eq'.

    Why aren't you using warnings?

    --

    See the Copyright notice on my home node.

    Perl training courses

    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: calling problem in script
by kennethk (Abbot) on Jun 30, 2009 at 14:31 UTC
    In addition to the comparison issue pointed out above, one issue I notice is that you use $Prefix in in your GetOptions call but build your glob with $prefix. This would definitely be caught with use of strict/warnings.
Re: calling problem in script
by jwkrahn (Abbot) on Jun 30, 2009 at 14:41 UTC
    printf "log files = \n"; print @log_paths; printf "\n";

    Your printf format strings do not have any conversion specifications and therefore you don't really need printf and should probably just be using print instead:

    print "log files = \n", @log_paths, "\n";
    A reply falls below the community's threshold of quality. You may see it by logging in.
Re: calling problem in script
by Anonymous Monk on Jun 30, 2009 at 14:27 UTC
Re: calling problem in script
by ww (Archbishop) on Jun 30, 2009 at 21:16 UTC

    Mostly as a matter of curiousity, why is your entire "piece of code" in sub main {...} except for the call to main() ???   Is there more you're not showing us?

      Cargoculting. He heard somewhere that the code he wants to run when the script/program gets executed belongs to the function named main() and did not notice those people were talking about a different language.

      Jenda
      Enoch was right!
      Enjoy the last years of Rome.