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/;
}
|