Lou Hernsen <mailto:[EMAIL PROTECTED]> wrote:

: "Charles K. Clarkson" <[EMAIL PROTECTED]>
: 
: : Lou Hernsen <mailto:[EMAIL PROTECTED]> wrote:
: : 
: : : Bareword "stats" not allowed while "strict subs" in use at
: : : C:\WWW\MYSTIC~1\CGI-BIN\TEST-N~1\MA.CGI line 4359. Execution
: : : of C:\WWW\MYSTIC~1\CGI-BIN\TEST-N~1\MA.CGI aborted due to
: : : compilation errors
: : 
: :     What's on the lines near line 4359?
: 
: stats;
: the command to call the module.

    We don't "call" modules. We load them using "use", then we
use them according to how they were written. In the old thread you
wanted to import a subroutine named Speed(). To use that sub on
line 4359, you would call it like this. The error from perl
indicates that you did not export a sub named stats().

Speed();


    The reason for this is because Stats.pm might have a hundreds
of subroutines in it. If we had to call all of them on each use of
any of them, we'd be up that smelly old creek. Remember how CGI.pm
works. We call it at the top of the script and then call its
imported subroutines as if we had written them in the "main" name
space.



HTH,


Charles K. Clarkson
-- 
Mobile Homes Specialist
254 968-8328

PS

    The original name of the package was "Stats", not "stats".
"use" is case sensitive. The module should have a name which
matches the package name.


# In a file named "Stats.pm"
package Stats;

use Exporter 'import';

# Any element of this array will be imported into
# calling package namespace (probably main::).
@EXPORT = qw(Speed);

sub Speed
{
 $v0 = 1+$Army+$Hero+$Spy;
 $v1 = 1+$Army+$Hero+$Spy+$Wagon;
 if  ($Wagon < 1 && $Horse >= $v0
  && $Saddle >= $v0 && $Blanket >= $v0
  && $Load <= 100)
    {$Speed = "1.5";}
 elsif ($Wagon == 0 && $Horse >= $v0 && $Load <= 100)
    {$Speed = "2";}
 elsif ($Wagon > 0 && $Horse >= $v1 && $Load <= 100)
  {$Speed = "2.5";}
 elsif ($Wagon == 0 && $Load <= 100)
  {$Speed = "3";}
 elsif ($Load > 100)
  {$Speed = (int(.3 * $Load))/10;}
 else {$Speed=3;}

 # Do your HTML stuff
}

1;


-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to