home *** CD-ROM | disk | FTP | other *** search
/ InfoMagic Source Code 1993 July / THE_SOURCE_CODE_CD_ROM.iso / languages / perl / scripts-osu / operl.shar / sample4 < prev    next >
Encoding:
Text File  |  1991-02-25  |  751 b   |  33 lines

  1. #!/usr/bin/perl
  2. require 'stack.pl';
  3.  
  4. # create two instances of class 'stack'
  5. $s1 = &newobject('stack');
  6. $s2 = &newobject('stack');
  7.  
  8. # push items onto stack $s1
  9. &send($s1, 'push', 10);
  10. &send($s1, 'push', 20);
  11. &send($s1, 'push', 30);
  12.  
  13. print "top of stack 1=" . &send($s1, 'top') . "\n";
  14. print "--- dump of stack 1 ---\n";
  15. &send($s1, 'dump');
  16.  
  17. &send($s2, 'push', 'Hello, world.');
  18. print "top of stack 2=" . &send($s2, 'top') . "\n";
  19.  
  20. print "--- show me ---\n";
  21. &send($s1, 'show_self');
  22. print "--- show me ---\n";
  23. &send($s2, 'show_self');
  24.  
  25. &send($s1, 'pop');
  26. print "top of stack 1=" . &send($s1, 'top') . "\n";
  27.  
  28. &send($s1, 'pop');
  29. print "top of stack 1=" . &send($s1, 'top') . "\n";
  30.  
  31. &send($s1, 'pop');
  32. print "top of stack 1=" . &send($s1, 'top') . "\n";
  33.