Closed Thread
Results 1 to 4 of 4

Thread: Hmm, what am I missing?

  1. #1
    Join Date
    May 2008
    Posts
    27
    Rep Power
    0

    Hmm, what am I missing?

    When test-running one of my perl scripts, I encountered something very strange.

    The main file requires two other scripts. The first two lines under the #! are require statements. Like so

    Code:
    #!/usr/bin/perl
    require "IOcontrolAlg.pl";
    require "FuncList.pl";
    .
    .
    .
    .
    Both of the scripts only have functions that are to be called by the main program. When the function call is encountered by the main script, it doesn't call the function.

    In pseudo-code, it looks slightly like this:

    Code:
    #!/usr/bin/perl
    require "funclist.pl"
    
    while ($input = <SDTIN>){
    chomp($input);
    if ($input eq "test1\"){
    function1; #where function1 is a function in 'funclist.pl'
    }
    else {
    function2; #where function2 is a function in 'funclist.pl'
    }
    }
    Programming is an art form. Everyone can program, but few can do it right.

  2. CODECALL Circuit advertisement
    Join Date
    Always
    Posts
    Many

     
  3. #2
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0

    Re: Hmm, what am I missing?

    It should work. If it doesn't work you should post any error messages you are getting. If the code is not too long you can also post the code.

  4. #3
    Join Date
    May 2008
    Posts
    27
    Rep Power
    0

    Re: Hmm, what am I missing?

    There is no error, but the main perl script is not calling any of the functions in the other scripts.

    code for the main file:
    Code:
    #!/usr/bin/perl
    #the main files used
    require "Mathfunc.pl";
    require "IOcontrol.pl";
    
    print <<STARTUP;
    ///////////////////////////////////////
    /Command Line Calculator (version 0.0)/
    /                                     /
    /If you are new, type in 'help'.      /
    /                                     /
    /For version history, type in 'ver'.  /
    /                                     /
    /To continue on, type in 'calc'.      /
    / /////////////////////////////////////
    STARTUP
    
    $lobby = 1; #just to control flow
    
    while ($lobby == 1){
    $input = <STDIN>;
    chomp($input);
    if ($input eq "help"){
    helpfile; #where this is a function in another file
    }
    elsif ($input eq "ver"){
    version; #where this is a function in another file
    }
    elsif ($input eq "calc"){
    $lobby = 0;
    }
    else {
    print "unrecognized command\n";
    }
    }
    .
    .
    .
    .
    .
    The scripts together will make a calculator, where 'IOcontrol.pl' parses what the user types in (such as "56+24" or "cos(56.326)"), making sure it's valid, then figures out what function in 'Mathfunc.pl'.

    I managed my way around '@inc', but when I type something in at the start, like 'help', it just sits there, not doing a thing.
    Programming is an art form. Everyone can program, but few can do it right.

  5. #4
    KevinADC is offline Programmer
    Join Date
    Jan 2007
    Posts
    125
    Rep Power
    0

    Re: Hmm, what am I missing?

    Turn on warnings (-w):

    #!/usr/bin/perl -w
    #the main files used
    require "Mathfunc.pl";
    require "IOcontrol.pl";

    that will warn of any problems in the main script or any of the required scripts. Retry the code with warnings on and see if you get any warnings.

Closed Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. What am I missing?!
    By jcampos8782 in forum C and C++
    Replies: 3
    Last Post: 02-11-2011, 01:38 AM
  2. File missing
    By ahmed in forum Linux Installation & Configuration
    Replies: 1
    Last Post: 06-04-2010, 02:30 AM
  3. Ntdrl Missing
    By arifsandwip in forum Computer Hardware
    Replies: 4
    Last Post: 04-12-2009, 10:03 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts