home *** CD-ROM | disk | FTP | other *** search
/ Peanuts NeXT Software Archives / Peanuts-2.iso / Developer / webobjects / extensions / win-nt / WOPerl-lite-10e7.exe / Examples / WOPerl / Visitors / Application.pl next >
Encoding:
Perl Script  |  1996-08-09  |  1.7 KB  |  48 lines

  1. # $Id: Application.pl,v 1.1 1996/07/26 05:19:01 pedja Exp $
  2. # Application.pl: converted from the original Application.wos
  3. # The original file contains the following notice:
  4. #
  5. #  You may freely copy, distribute, and reuse the code in this example.
  6. #  NeXT disclaims any warranty of any kind, expressed or  implied, as to its
  7. #  fitness for any particular use.
  8. #
  9. #     Written by Katie McCormick
  10. #
  11. #  This application displays the name of the most recent visitor and the
  12. #  total number of visitors to the page. The Application.wos script
  13. #  declares two global variables: lastVisitor (which holds the name of the
  14. #  most recent visitor), and visitorsNum (which holds the total number of
  15. #  people who have visited the page since the application was launched).
  16. #
  17. #  You can access global variables from any other script in an
  18. #  application by sending a message to WOApp. For example, to set and
  19. #  return the values of lastVisitor and visitorNum from another script,
  20. #  you'd use the syntax:
  21. #  
  22. #  $WOApp->lastVisitor;            # return lastVisitor
  23. #  $WOApp->setLastVisitor($aValue);    # set value of lastVisitor
  24. #  $WOApp->visitorNum;            # return visitorNum
  25. #  $WOApp->setVisitorNum($aValue);    # set value of visitorNum
  26. #
  27. #  Note that these "accessor methods" aren't defined anywhere. In WOPerl, 
  28. #  you can access script variables with such accessor methods without having
  29. #  to define them.
  30.  
  31. package WO::Visitors;
  32. use WOPerl;
  33.  
  34. @IVARS=qw(lastVisitor visitorNum);
  35. # lastVisitor: the most recent visitor
  36. # visitorNum: the total number of visitors the page
  37.  
  38. sub awake 
  39. {
  40.   my $self=shift;
  41.   # Obsolete sessions that have been inactive for more than 2 minutes
  42.   $WOApp->setSessionTimeOut(120);
  43.   $self->{'visitorNum'} = 0; 
  44. }
  45.  
  46. 'WO::Visitors';
  47. # EOF
  48.