1 2 | perl -MCPAN -e'install Tk' perl -MCPAN -e'install Devel::ptkdb' |
1 | perl -d:ptkdb buggy.pl buggy.pl |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | #!/usr/bin/perl -w use Term::ReadLine; use Data:umper; my $historyfile = $ENV{HOME} . '/.phistory'; my $term = new Term::ReadLine 'Perl Shell'; sub save_list { my $f = shift; my $l = shift; open F, $f; print F "$_\n" foreach @$l } if (open H, $historyfile) { @h = ; chomp @h; close H; $h{$_} = 1 foreach @h; $term->addhistory($_) foreach keys %h; } while ( defined ($_ = $term->readline("My Perl Shell> ")) ) { my $res = eval($_); warn $@ if $@; unless ($@) { open H, ">>$historyfile"; print H "$_\n"; close H; print "\n", Data:umper->Dump([$res], ['Result']); } $term->addhistory($_) if /\S/; } |
1 2 3 4 5 | Da Perl Shell> use strict $Result = undef; Perl Shell> print "$_: " . <> foreach (0..20) 0: ... 1: ... |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 | Perl Shell> open F, "buggy.pl" $Result = 1; Perl Shell> foreach (0..20) { last if eof(F); print "$_: " . ; } 0: #!/usr/bin/perl -w 1: 2: use strict; 3: 4: foreach (0..20) 5: { 6: my $line = <>; 7: last unless defined $line; # exit loop if $line is not defined 8: print "$_ : $line"; 9: } $Result = undef; |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |