So I've had it in the back of my head to make something as a shortcut. Implementing a "run contents as Perl" command for my usual text editor has issues: I still have to come up with a name, and it's not running under a console (text) environment.
So, I thought about a real simple Perl program that has a edit box and a Run button. (see end for concept code)
Now that it's underway, I'm thinking about other features. Here's a question: How can I separate out compiler errors from program's output? The program may itself write to STDERR, so if I can get Perl to write to someplace else... then the editor can parse errors and position the cursor. Note that I'm running another copy of Perl, not simply eval-ing the code, so it can always have a clean environment.
All thoughts welcome.
—John
use strict; use warnings; use utf8; use Tk; ${^WIDE_SYSTEM_CALLS}= 1; my $MW = new MainWindow; my $text= $MW->Scrolled(qw/Text -relief sunken -borderwidth 2 -wrap no +ne -height 30 -scrollbars e/) ->pack(qw/-expand yes -fill both/); my $frame= $MW->Frame()->pack(); $frame->Button( -text => 'Run', -command => \&do_run ) ->pack (-side => 'left'); $frame->Button( -text => 'Save' ) -> pack (-side =>'left'); $text->insert ('0.0', "use v5.6.1;\nuse strict;\nuse warnings;\n\n"); MainLoop; ################3 sub do_run { my $s= $text->get('1.0','end'); open OUTFILE, "> quick_run.perl" or die "Cannot save file."; print OUTFILE $s; close OUTFILE; system "perl quick_run.perl"; }
In reply to QuickPerl: a step up from -e by John M. Dlugosz
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |