home *** CD-ROM | disk | FTP | other *** search
- #!/usr/bin/perl
- require 'operl.pl';
-
- &defclass ('stack','root');
- &defmethod('stack','init','$inx = 0');
- &defmethod('stack','push','$stk[$inx++] = $_[0];');
- &defmethod('stack','pop',
- 'warn "warn: empty stack.\n" if ($inx <= 0);$inx -- if $inx > 0;');
- &defmethod('stack','top',
- 'warn "warn: empty stack.\n" if ($inx <= 0);$stk[$inx - 1]');
- &defmethod('stack','length','$inx;');
- &defmethod('stack','dump','foreach $item (@stk) {print "(" . $item . ")\n";}');
-
- 1;
-