1#!/usr/local/bin/perl 2# Copyright © 2007 Alexis Sukrieh 3# 4# This program is free software; you can redistribute it and/or modify it under 5# the terms of the GNU General Public License as published by the Free Software 6# Foundation; either version 2 of the License, or (at your option) any later 7# version. 8# 9# This program is distributed in the hope that it will be useful, but WITHOUT 10# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 11# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more 12# details. 13# 14# You should have received a copy of the GNU General Public License along with 15# this program; if not, write to the Free Software Foundation, Inc., 51 16# Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 17 18# Perl Console is a small program that lets you evaluates Perl code 19# interactively. It uses Readline for grabing input and provide completion 20# with all the namespaces loaded during your session. 21# This is the main script of the program. 22 23# strict mode 24use strict; 25use warnings; 26 27# libs 28use PerlConsole; 29use PerlConsole::Console; 30 31# Init our console 32my $console = PerlConsole::Console->new($PerlConsole::VERSION); 33 34# look for option in the commandline 35$console->parse_options(); 36 37# display the header message 38$console->header(); 39 40# source the rcfile first 41$console->source_rcfile(); 42 43# Main REPL, prompting and waiting for code to evaluate 44while (defined (my $code = $console->getInput())) { 45 $console->interpret($code); 46} 47 48# End, quitting. 49$console->clean_exit(0); 50 51__END__ 52=pod 53 54=head1 NAME 55 56perlconsole 57 58=head1 COPYRIGHT 59 60Perl Console is Copyright (C) 2007 by Alexis Sukrieh 61 62=head1 DESCRIPTION 63 64Perl Console is a small program that implements a Read-eval-print loop: it lets 65you evaluate Perl code interactively. 66 67It uses Readline to grab input, and provides completion with all the namespaces 68loaded during your session. It allows you to load a module in your session and 69test a function exported by it. 70 71=head1 COMMANDS 72 73It's possible to interact with the console with internal commands. The 74following commands are supported in this version: 75 76=over 4 77 78=item B<:help> display the interactive help screen 79 80=item B<:quit> quit the console 81 82=item B<:set> set a preference (see PREFERENCES). 83 84=back 85 86=head1 RCFILE 87 88PerlConsole will look for a rcfile located in your home directory called: 89~/.perlconsolerc 90 91Every line in that file will be evaluated as if they were issued in the console. 92You can then load there your favorite modules, or even define your preferences. 93 94Example of a valid ~/.perlconsolerc 95 96 :set output = dumper 97 use Date::Calc; 98 99 100=head1 PREFERENCES 101 102Preferences can be set with the B<:set> command. The following preferences are 103supported in this version: 104 105=over 4 106 107=item B<output> changes the output of evaluated code 108 109=back 110 111For details about commands, ype :help <command> within the console. 112 113=head1 AUTHOR 114 115Perl Console was writen by Alexis Sukrieh <sukria@sukria.net>. 116 117=cut 118