Next Unix Command Internals 21

Current directory

        %builtin = (cd => sub { chdir $_[0] 
                                  || warn "Couldn't chdir to $_[0]: $!\n"; },
                    exit => sub { exit $_[0] || 0 },
                    );
        while (1) {
          print "perl% ";
          my $command = <STDIN>;
          last if $command eq '';
          chomp $command;
          my (%command) = parse($command);
          if (defined $builtin{$command{program}}) {
            $builtin{$command{program}}->(@{$command{args}});
            next;
          }
          ...
        }


Next Copyright © 2003 M. J. Dominus