Thursday, June 24, 2010

Updated interactive perl script

This is still just a quick script to test out perl concepts before trying to write them into a program. It isn't fancy but it is functional.

Look for more updates as I build this out a bit more:
#!/usr/bin/env perl

use Term::ReadLine;
use strict;
use warnings;

my $prompt = "> ";

my $term = new Term::ReadLine("iPerl -- interactive perl");

while (defined ($_ = $term->readline($prompt))) {
chomp;

next if (/^\s$/);
last if (/^(?:q|quit|exit|logout)$/);

my $output = eval $_ or print $!;

print "\nOUT: $output\n" if $output;
}

print "\n";

No comments: