home *** CD-ROM | disk | FTP | other *** search
/ Borland Programmer's Resource / Borland_Programmers_Resource_CD_1995.iso / ntcode / ntperlb / lib / perldb.pl < prev    next >
Encoding:
Perl Script  |  1995-05-19  |  16.6 KB  |  599 lines

  1. package DB;
  2.  
  3. # modified Perl debugger, to be run from Emacs in perldb-mode
  4. # Ray Lischner (uunet!mntgfx!lisch) as of 5 Nov 1990
  5. # Johan Vromans -- upgrade to 4.0 pl 10
  6.  
  7. $header = '$RCSfile: perldb.pl,v $$Revision: 1.1 $$Date: 1993/04/22 15:49:12 $';
  8. #
  9. # This file is automatically included if you do perl -d.
  10. # It's probably not useful to include this yourself.
  11. #
  12. # Perl supplies the values for @line and %sub.  It effectively inserts
  13. # a do DB'DB(<linenum>); in front of every place that can
  14. # have a breakpoint.  It also inserts a do 'perldb.pl' before the first line.
  15. #
  16. # $Log: perldb.pl,v $
  17. # Revision 1.1  1993/04/22  15:49:12  isdk
  18. # Initial load of perl source for NT port
  19. #
  20. # Revision 4.0.1.3  92/06/08  13:43:57  lwall
  21. # patch20: support for MSDOS folded into perldb.pl
  22. # patch20: perldb couldn't debug file containing '-', such as STDIN designator
  23. # Revision 4.0.1.2  91/11/05  17:55:58  lwall
  24. # patch11: perldb.pl modified to run within emacs in perldb-mode
  25. # Revision 4.0.1.1  91/06/07  11:17:44  lwall
  26. # patch4: added $^P variable to control calling of perldb routines
  27. # patch4: debugger sometimes listed wrong number of lines for a statement
  28. # Revision 4.0  91/03/20  01:25:50  lwall
  29. # 4.0 baseline.
  30. # Revision 3.0.1.6  91/01/11  18:08:58  lwall
  31. # patch42: @_ couldn't be accessed from debugger
  32. # Revision 3.0.1.5  90/11/10  01:40:26  lwall
  33. # patch38: the debugger wouldn't stop correctly or do action routines
  34. # Revision 3.0.1.4  90/10/15  17:40:38  lwall
  35. # patch29: added caller
  36. # patch29: the debugger now understands packages and evals
  37. # patch29: scripts now run at almost full speed under the debugger
  38. # patch29: more variables are settable from debugger
  39. # Revision 3.0.1.3  90/08/09  04:00:58  lwall
  40. # patch19: debugger now allows continuation lines
  41. # patch19: debugger can now dump lists of variables
  42. # patch19: debugger can now add aliases easily from prompt
  43. # Revision 3.0.1.2  90/03/12  16:39:39  lwall
  44. # patch13: perl -d didn't format stack traces of *foo right
  45. # patch13: perl -d wiped out scalar return values of subroutines
  46. # Revision 3.0.1.1  89/10/26  23:14:02  lwall
  47. # patch1: RCS expanded an unintended $Header in lib/perldb.pl
  48. # Revision 3.0  89/10/18  15:19:46  lwall
  49. # 3.0 baseline
  50. # Revision 2.0  88/06/05  00:09:45  root
  51. # Baseline version 2.0.
  52. #
  53.  
  54. if (-e "/dev/tty") {
  55.     $console = "/dev/tty";
  56.     $rcfile=".perldb";
  57. }
  58. else {
  59.     $console = "con";
  60.     $rcfile="perldb.ini";
  61. }
  62.  
  63. open(IN, "<$console") || open(IN,  "<&STDIN");    # so we don't dingle stdin
  64. open(OUT,">$console") || open(OUT, ">&STDOUT");    # so we don't dongle stdout
  65. select(OUT);
  66. $| = 1;                # for DB'OUT
  67. select(STDOUT);
  68. $| = 1;                # for real STDOUT
  69. $sub = '';
  70.  
  71. # Is Perl being run from Emacs?
  72. $emacs = $main'ARGV[$[] eq '-emacs';
  73. shift(@main'ARGV) if $emacs;
  74.  
  75. $header =~ s/.Header: ([^,]+),v(\s+\S+\s+\S+).*$/$1$2/;
  76. print OUT "\nLoading DB routines from $header\n";
  77. print OUT ("Emacs support ",
  78.        $emacs ? "enabled" : "available",
  79.        ".\n");
  80. print OUT "\nEnter h for help.\n\n";
  81.  
  82. sub DB {
  83.     &save;
  84.     ($package, $filename, $line) = caller;
  85.     $usercontext = '($@, $!, $[, $,, $/, $\) = @saved;' .
  86.     "package $package;";        # this won't let them modify, alas
  87.     local($^P) = 0;            # don't debug our own evals
  88.     local(*dbline) = "_<$filename";
  89.     $max = $#dbline;
  90.     if (($stop,$action) = split(/\0/,$dbline{$line})) {
  91.     if ($stop eq '1') {
  92.         $signal |= 1;
  93.     }
  94.     else {
  95.         $evalarg = "\$DB'signal |= do {$stop;}"; &eval;
  96.         $dbline{$line} =~ s/;9($|\0)/$1/;
  97.     }
  98.     }
  99.     if ($single || $trace || $signal) {
  100.     if ($emacs) {
  101.         print OUT "\032\032$filename:$line:0\n";
  102.     } else {
  103.         print OUT "$package'" unless $sub =~ /'/;
  104.         print OUT "$sub($filename:$line):\t",$dbline[$line];
  105.         for ($i = $line + 1; $i <= $max && $dbline[$i] == 0; ++$i) {
  106.         last if $dbline[$i] =~ /^\s*(}|#|\n)/;
  107.         print OUT "$sub($filename:$i):\t",$dbline[$i];
  108.         }
  109.     }
  110.     }
  111.     $evalarg = $action, &eval if $action;
  112.     if ($single || $signal) {
  113.     $evalarg = $pre, &eval if $pre;
  114.     print OUT $#stack . " levels deep in subroutine calls!\n"
  115.         if $single & 4;
  116.     $start = $line;
  117.       CMD:
  118.     while ((print OUT "  DB<", $#hist+1, "> "), $cmd=&gets) {
  119.         {
  120.         $single = 0;
  121.         $signal = 0;
  122.         $cmd eq '' && exit 0;
  123.         chop($cmd);
  124.         $cmd =~ s/\\$// && do {
  125.             print OUT "  cont: ";
  126.             $cmd .= &gets;
  127.             redo CMD;
  128.         };
  129.         $cmd =~ /^q$/ && exit 0;
  130.         $cmd =~ /^$/ && ($cmd = $laststep);
  131.         push(@hist,$cmd) if length($cmd) > 1;
  132.         ($i) = split(/\s+/,$cmd);
  133.         eval "\$cmd =~ $alias{$i}", print OUT $@ if $alias{$i};
  134.         $cmd =~ /^h$/ && do {
  135.             print OUT "
  136. T        Stack trace.
  137. s        Single step.
  138. n        Next, steps over subroutine calls.
  139. r        Return from current subroutine.
  140. c [line]    Continue; optionally inserts a one-time-only breakpoint 
  141.         at the specified line.
  142. <CR>        Repeat last n or s.
  143. l min+incr    List incr+1 lines starting at min.
  144. l min-max    List lines.
  145. l line        List line;
  146. l        List next window.
  147. -        List previous window.
  148. w line        List window around line.
  149. l subname    List subroutine.
  150. f filename    Switch to filename.
  151. /pattern/    Search forwards for pattern; final / is optional.
  152. ?pattern?    Search backwards for pattern.
  153. L        List breakpoints and actions.
  154. S        List subroutine names.
  155. t        Toggle trace mode.
  156. b [line] [condition]
  157.         Set breakpoint; line defaults to the current execution line; 
  158.         condition breaks if it evaluates to true, defaults to \'1\'.
  159. b subname [condition]
  160.         Set breakpoint at first line of subroutine.
  161. d [line]    Delete breakpoint.
  162. D        Delete all breakpoints.
  163. a [line] command
  164.         Set an action to be done before the line is executed.
  165.         Sequence is: check for breakpoint, print line if necessary,
  166.         do action, prompt user if breakpoint or step, evaluate line.
  167. A        Delete all actions.
  168. V [pkg [vars]]    List some (default all) variables in package (default current).
  169. X [vars]    Same as \"V currentpackage [vars]\".
  170. < command    Define command before prompt.
  171. > command    Define command after prompt.
  172. ! number    Redo command (default previous command).
  173. ! -number    Redo number\'th to last command.
  174. H -number    Display last number commands (default all).
  175. q or ^D        Quit.
  176. p expr        Same as \"print DB'OUT expr\" in current package.
  177. = [alias value]    Define a command alias, or list current aliases.
  178. command        Execute as a perl statement in current package.
  179.  
  180. ";
  181.             next CMD; };
  182.         $cmd =~ /^t$/ && do {
  183.             $trace = !$trace;
  184.             print OUT "Trace = ".($trace?"on":"off")."\n";
  185.             next CMD; };
  186.         $cmd =~ /^S$/ && do {
  187.             foreach $subname (sort(keys %sub)) {
  188.             print OUT $subname,"\n";
  189.             }
  190.             next CMD; };
  191.         $cmd =~ s/^X\b/V $package/;
  192.         $cmd =~ /^V$/ && do {
  193.             $cmd = 'V $package'; };
  194.         $cmd =~ /^V\b\s*(\S+)\s*(.*)/ && do {
  195.             $packname = $1;
  196.             @vars = split(' ',$2);
  197.             do 'dumpvar.pl' unless defined &main'dumpvar;
  198.             if (defined &main'dumpvar) {
  199.             &main'dumpvar($packname,@vars);
  200.             }
  201.             else {
  202.             print DB'OUT "dumpvar.pl not available.\n";
  203.             }
  204.             next CMD; };
  205.         $cmd =~ /^f\b\s*(.*)/ && do {
  206.             $file = $1;
  207.             if (!$file) {
  208.             print OUT "The old f command is now the r command.\n";
  209.             print OUT "The new f command switches filenames.\n";
  210.             next CMD;
  211.             }
  212.             if (!defined $_main{'_<' . $file}) {
  213.             if (($try) = grep(m#^_<.*$file#, keys %_main)) {
  214.                 $file = substr($try,2);
  215.                 print "\n$file:\n";
  216.             }
  217.             }
  218.             if (!defined $_main{'_<' . $file}) {
  219.             print OUT "There's no code here anything matching $file.\n";
  220.             next CMD;
  221.             }
  222.             elsif ($file ne $filename) {
  223.             *dbline = "_<$file";
  224.             $max = $#dbline;
  225.             $filename = $file;
  226.             $start = 1;
  227.             $cmd = "l";
  228.             } };
  229.         $cmd =~ /^l\b\s*(['A-Za-z_]['\w]*)/ && do {
  230.             $subname = $1;
  231.             $subname = "main'" . $subname unless $subname =~ /'/;
  232.             $subname = "main" . $subname if substr($subname,0,1) eq "'";
  233.             ($file,$subrange) = split(/:/,$sub{$subname});
  234.             if ($file ne $filename) {
  235.             *dbline = "_<$file";
  236.             $max = $#dbline;
  237.             $filename = $file;
  238.             }
  239.             if ($subrange) {
  240.             if (eval($subrange) < -$window) {
  241.                 $subrange =~ s/-.*/+/;
  242.             }
  243.             $cmd = "l $subrange";
  244.             } else {
  245.             print OUT "Subroutine $1 not found.\n";
  246.             next CMD;
  247.             } };
  248.         $cmd =~ /^w\b\s*(\d*)$/ && do {
  249.             $incr = $window - 1;
  250.             $start = $1 if $1;
  251.             $start -= $preview;
  252.             $cmd = 'l ' . $start . '-' . ($start + $incr); };
  253.         $cmd =~ /^-$/ && do {
  254.             $incr = $window - 1;
  255.             $cmd = 'l ' . ($start-$window*2) . '+'; };
  256.         $cmd =~ /^l$/ && do {
  257.             $incr = $window - 1;
  258.             $cmd = 'l ' . $start . '-' . ($start + $incr); };
  259.         $cmd =~ /^l\b\s*(\d*)\+(\d*)$/ && do {
  260.             $start = $1 if $1;
  261.             $incr = $2;
  262.             $incr = $window - 1 unless $incr;
  263.             $cmd = 'l ' . $start . '-' . ($start + $incr); };
  264.         $cmd =~ /^l\b\s*(([\d\$\.]+)([-,]([\d\$\.]+))?)?/ && do {
  265.             $end = (!$2) ? $max : ($4 ? $4 : $2);
  266.             $end = $max if $end > $max;
  267.             $i = $2;
  268.             $i = $line if $i eq '.';
  269.             $i = 1 if $i < 1;
  270.             if ($emacs) {
  271.             print OUT "\032\032$filename:$i:0\n";
  272.             $i = $end;
  273.             } else {
  274.             for (; $i <= $end; $i++) {
  275.                 print OUT "$i:\t", $dbline[$i];
  276.                 last if $signal;
  277.             }
  278.             }
  279.             $start = $i;    # remember in case they want more
  280.             $start = $max if $start > $max;
  281.             next CMD; };
  282.         $cmd =~ /^D$/ && do {
  283.             print OUT "Deleting all breakpoints...\n";
  284.             for ($i = 1; $i <= $max ; $i++) {
  285.             if (defined $dbline{$i}) {
  286.                 $dbline{$i} =~ s/^[^\0]+//;
  287.                 if ($dbline{$i} =~ s/^\0?$//) {
  288.                 delete $dbline{$i};
  289.                 }
  290.             }
  291.             }
  292.             next CMD; };
  293.         $cmd =~ /^L$/ && do {
  294.             for ($i = 1; $i <= $max; $i++) {
  295.             if (defined $dbline{$i}) {
  296.                 print OUT "$i:\t", $dbline[$i];
  297.                 ($stop,$action) = split(/\0/, $dbline{$i});
  298.                 print OUT "  break if (", $stop, ")\n" 
  299.                 if $stop;
  300.                 print OUT "  action:  ", $action, "\n" 
  301.                 if $action;
  302.                 last if $signal;
  303.             }
  304.             }
  305.             next CMD; };
  306.         $cmd =~ /^b\b\s*(['A-Za-z_]['\w]*)\s*(.*)/ && do {
  307.             $subname = $1;
  308.             $cond = $2 || '1';
  309.             $subname = "$package'" . $subname unless $subname =~ /'/;
  310.             $subname = "main" . $subname if substr($subname,0,1) eq "'";
  311.             ($filename,$i) = split(/:/, $sub{$subname});
  312.             $i += 0;
  313.             if ($i) {
  314.             *dbline = "_<$filename";
  315.             ++$i while $dbline[$i] == 0 && $i < $#dbline;
  316.             $dbline{$i} =~ s/^[^\0]*/$cond/;
  317.             } else {
  318.             print OUT "Subroutine $subname not found.\n";
  319.             }
  320.             next CMD; };
  321.         $cmd =~ /^b\b\s*(\d*)\s*(.*)/ && do {
  322.             $i = ($1?$1:$line);
  323.             $cond = $2 || '1';
  324.             if ($dbline[$i] == 0) {
  325.             print OUT "Line $i not breakable.\n";
  326.             } else {
  327.             $dbline{$i} =~ s/^[^\0]*/$cond/;
  328.             }
  329.             next CMD; };
  330.         $cmd =~ /^d\b\s*(\d+)?/ && do {
  331.             $i = ($1?$1:$line);
  332.             $dbline{$i} =~ s/^[^\0]*//;
  333.             delete $dbline{$i} if $dbline{$i} eq '';
  334.             next CMD; };
  335.         $cmd =~ /^A$/ && do {
  336.             for ($i = 1; $i <= $max ; $i++) {
  337.             if (defined $dbline{$i}) {
  338.                 $dbline{$i} =~ s/\0[^\0]*//;
  339.                 delete $dbline{$i} if $dbline{$i} eq '';
  340.             }
  341.             }
  342.             next CMD; };
  343.         $cmd =~ /^<\s*(.*)/ && do {
  344.             $pre = do action($1);
  345.             next CMD; };
  346.         $cmd =~ /^>\s*(.*)/ && do {
  347.             $post = do action($1);
  348.             next CMD; };
  349.         $cmd =~ /^a\b\s*(\d+)(\s+(.*))?/ && do {
  350.             $i = $1;
  351.             if ($dbline[$i] == 0) {
  352.             print OUT "Line $i may not have an action.\n";
  353.             } else {
  354.             $dbline{$i} =~ s/\0[^\0]*//;
  355.             $dbline{$i} .= "\0" . do action($3);
  356.             }
  357.             next CMD; };
  358.         $cmd =~ /^n$/ && do {
  359.             $single = 2;
  360.             $laststep = $cmd;
  361.             last CMD; };
  362.         $cmd =~ /^s$/ && do {
  363.             $single = 1;
  364.             $laststep = $cmd;
  365.             last CMD; };
  366.         $cmd =~ /^c\b\s*(\d*)\s*$/ && do {
  367.             $i = $1;
  368.             if ($i) {
  369.             if ($dbline[$i] == 0) {
  370.                 print OUT "Line $i not breakable.\n";
  371.                 next CMD;
  372.             }
  373.             $dbline{$i} =~ s/(\0|$)/;9$1/;    # add one-time-only b.p.
  374.             }
  375.             for ($i=0; $i <= $#stack; ) {
  376.             $stack[$i++] &= ~1;
  377.             }
  378.             last CMD; };
  379.         $cmd =~ /^r$/ && do {
  380.             $stack[$#stack] |= 2;
  381.             last CMD; };
  382.         $cmd =~ /^T$/ && do {
  383.             local($p,$f,$l,$s,$h,$a,@a,@sub);
  384.             for ($i = 1; ($p,$f,$l,$s,$h,$w) = caller($i); $i++) {
  385.             @a = @args;
  386.             for (@a) {
  387.                 if (/^StB\000/ && length($_) == length($_main{'_main'})) {
  388.                 $_ = sprintf("%s",$_);
  389.                 }
  390.                 else {
  391.                 s/'/\\'/g;
  392.                 s/([^\0]*)/'$1'/ unless /^-?[\d.]+$/;
  393.                 s/([\200-\377])/sprintf("M-%c",ord($1)&0177)/eg;
  394.                 s/([\0-\37\177])/sprintf("^%c",ord($1)^64)/eg;
  395.                 }
  396.             }
  397.             $w = $w ? '@ = ' : '$ = ';
  398.             $a = $h ? '(' . join(', ', @a) . ')' : '';
  399.             push(@sub, "$w&$s$a from file $f line $l\n");
  400.             last if $signal;
  401.             }
  402.             for ($i=0; $i <= $#sub; $i++) {
  403.             last if $signal;
  404.             print OUT $sub[$i];
  405.             }
  406.             next CMD; };
  407.         $cmd =~ /^\/(.*)$/ && do {
  408.             $inpat = $1;
  409.             $inpat =~ s:([^\\])/$:$1:;
  410.             if ($inpat ne "") {
  411.             eval '$inpat =~ m'."\n$inpat\n";    
  412.             if ($@ ne "") {
  413.                 print OUT "$@";
  414.                 next CMD;
  415.             }
  416.             $pat = $inpat;
  417.             }
  418.             $end = $start;
  419.             eval '
  420.             for (;;) {
  421.             ++$start;
  422.             $start = 1 if ($start > $max);
  423.             last if ($start == $end);
  424.             if ($dbline[$start] =~ m'."\n$pat\n".'i) {
  425.                 if ($emacs) {
  426.                 print OUT "\032\032$filename:$start:0\n";
  427.                 } else {
  428.                 print OUT "$start:\t", $dbline[$start], "\n";
  429.                 }
  430.                 last;
  431.             }
  432.             } ';
  433.             print OUT "/$pat/: not found\n" if ($start == $end);
  434.             next CMD; };
  435.         $cmd =~ /^\?(.*)$/ && do {
  436.             $inpat = $1;
  437.             $inpat =~ s:([^\\])\?$:$1:;
  438.             if ($inpat ne "") {
  439.             eval '$inpat =~ m'."\n$inpat\n";    
  440.             if ($@ ne "") {
  441.                 print OUT "$@";
  442.                 next CMD;
  443.             }
  444.             $pat = $inpat;
  445.             }
  446.             $end = $start;
  447.             eval '
  448.             for (;;) {
  449.             --$start;
  450.             $start = $max if ($start <= 0);
  451.             last if ($start == $end);
  452.             if ($dbline[$start] =~ m'."\n$pat\n".'i) {
  453.                 if ($emacs) {
  454.                 print OUT "\032\032$filename:$start:0\n";
  455.                 } else {
  456.                 print OUT "$start:\t", $dbline[$start], "\n";
  457.                 }
  458.                 last;
  459.             }
  460.             } ';
  461.             print OUT "?$pat?: not found\n" if ($start == $end);
  462.             next CMD; };
  463.         $cmd =~ /^!+\s*(-)?(\d+)?$/ && do {
  464.             pop(@hist) if length($cmd) > 1;
  465.             $i = ($1?($#hist-($2?$2:1)):($2?$2:$#hist));
  466.             $cmd = $hist[$i] . "\n";
  467.             print OUT $cmd;
  468.             redo CMD; };
  469.         $cmd =~ /^!(.+)$/ && do {
  470.             $pat = "^$1";
  471.             pop(@hist) if length($cmd) > 1;
  472.             for ($i = $#hist; $i; --$i) {
  473.             last if $hist[$i] =~ $pat;
  474.             }
  475.             if (!$i) {
  476.             print OUT "No such command!\n\n";
  477.             next CMD;
  478.             }
  479.             $cmd = $hist[$i] . "\n";
  480.             print OUT $cmd;
  481.             redo CMD; };
  482.         $cmd =~ /^H\b\s*(-(\d+))?/ && do {
  483.             $end = $2?($#hist-$2):0;
  484.             $hist = 0 if $hist < 0;
  485.             for ($i=$#hist; $i>$end; $i--) {
  486.             print OUT "$i: ",$hist[$i],"\n"
  487.                 unless $hist[$i] =~ /^.?$/;
  488.             };
  489.             next CMD; };
  490.         $cmd =~ s/^p( .*)?$/print DB'OUT$1/;
  491.         $cmd =~ /^=/ && do {
  492.             if (local($k,$v) = ($cmd =~ /^=\s*(\S+)\s+(.*)/)) {
  493.             $alias{$k}="s~$k~$v~";
  494.             print OUT "$k = $v\n";
  495.             } elsif ($cmd =~ /^=\s*$/) {
  496.             foreach $k (sort keys(%alias)) {
  497.                 if (($v = $alias{$k}) =~ s~^s\~$k\~(.*)\~$~$1~) {
  498.                 print OUT "$k = $v\n";
  499.                 } else {
  500.                 print OUT "$k\t$alias{$k}\n";
  501.                 };
  502.             };
  503.             };
  504.             next CMD; };
  505.         }
  506.         $evalarg = $cmd; &eval;
  507.         print OUT "\n";
  508.     }
  509.     if ($post) {
  510.         $evalarg = $post; &eval;
  511.     }
  512.     }
  513.     ($@, $!, $[, $,, $/, $\) = @saved;
  514. }
  515.  
  516. sub save {
  517.     @saved = ($@, $!, $[, $,, $/, $\);
  518.     $[ = 0; $, = ""; $/ = "\n"; $\ = "";
  519. }
  520.  
  521. # The following takes its argument via $evalarg to preserve current @_
  522.  
  523. sub eval {
  524.     eval "$usercontext $evalarg; &DB'save";
  525.     print OUT $@;
  526. }
  527.  
  528. sub action {
  529.     local($action) = @_;
  530.     while ($action =~ s/\\$//) {
  531.     print OUT "+ ";
  532.     $action .= &gets;
  533.     }
  534.     $action;
  535. }
  536.  
  537. sub gets {
  538.     local($.);
  539.     <IN>;
  540. }
  541.  
  542. sub catch {
  543.     $signal = 1;
  544. }
  545.  
  546. sub sub {
  547.     push(@stack, $single);
  548.     $single &= 1;
  549.     $single |= 4 if $#stack == $deep;
  550.     if (wantarray) {
  551.     @i = &$sub;
  552.     $single |= pop(@stack);
  553.     @i;
  554.     }
  555.     else {
  556.     $i = &$sub;
  557.     $single |= pop(@stack);
  558.     $i;
  559.     }
  560. }
  561.  
  562. $single = 1;            # so it stops on first executable statement
  563. @hist = ('?');
  564. $SIG{'INT'} = "DB'catch";
  565. $deep = 100;        # warning if stack gets this deep
  566. $window = 10;
  567. $preview = 3;
  568.  
  569. @stack = (0);
  570. @ARGS = @ARGV;
  571. for (@args) {
  572.     s/'/\\'/g;
  573.     s/(.*)/'$1'/ unless /^-?[\d.]+$/;
  574. }
  575.  
  576. if (-f $rcfile) {
  577.     do "./$rcfile";
  578. }
  579. elsif (-f "$ENV{'LOGDIR'}/$rcfile") {
  580.     do "$ENV{'LOGDIR'}/$rcfile";
  581. }
  582. elsif (-f "$ENV{'HOME'}/$rcfile") {
  583.     do "$ENV{'HOME'}/$rcfile";
  584. }
  585.  
  586. 1;
  587.