I am trying to teach my daughter Perl. In order to improve her experience with Perl, I tried together with her to make an IDE for her.

What I posted here is just where we started, and we will surely continue to work on it, and use it for ourselves.

For the next revision, we will try to:
  1. make STDIN work
  2. visually link compilation errors with source code
  3. try to connect to debug
use Tk; use IPC::Open3; use Hash::Util (lock_keys); use strict; use warnings; $main::self = {}; $main::self->{OPEN_FILE} = undef; $main::self->{MAIN_WINDOW} = new MainWindow(title => "My Program - Unt +iled"); my $tools_frame = $main::self->{MAIN_WINDOW} ->Frame(border => 1, relief => "sunken") ->pack(fill => "x", padx => 5, pady => 5, side => "top"); my $run = $tools_frame->Button(text => "Run", background => "light blue", activebackground => "pink", command => \&run) ->pack(side => "left", padx => 5, pady => 5); $tools_frame->Button(text => "New", background => "light blue", activebackground => "pink", command => \&new_file) ->pack(side => "left", pady => 5); $tools_frame->Button(text => "Open", background => "light blue", activebackground => "pink", command => \&open_file) ->pack(side => "left", pady => 5); $tools_frame->Button(text => "Save", background => "light blue", activebackground => "pink", command => \&save) ->pack(side => "left", pady => 5); $tools_frame->Button(text => "Save As", background => "light blue", activebackground => "pink", command => \&save_as) ->pack(side => "left", pady => 5); $main::self->{PROGRAM_TEXT} = $main::self->{MAIN_WINDOW} ->Scrolled("Text", font => ["Times", 16], -scrollbars => "e", background => "cyan", width => 70, height => 20) ->pack(side => "top", fill => "x"); lock_keys(%{$main::self}); $main::result = $main::self->{MAIN_WINDOW} ->Scrolled("Text", font => ["Times", 16], -scrollbars => "e", background => "light green", width => 70, height => 8) ->pack(side => "top", fill => "x"); $main::self->{PROGRAM_TEXT}->focus(); MainLoop; sub run { my $program = $main::self->{PROGRAM_TEXT}->get("1.0", "end"); open(PROGRAM, ">", "program.pl"); print PROGRAM $program; close(PROGRAM); open3(\*WRITER, \*READER, \*READER, "perl", "-w", "program.pl"); $main::result->delete("1.0", "end"); while (my $content = <READER>) { $main::result->insert("end", $content); } } sub save_file { open(FILE, ">", $main::self->{OPEN_FILE}); my $program = $main::self->{PROGRAM_TEXT}->get("1.0", "end"); print FILE $program; close(FILE); } sub save { if ($main::self->{OPEN_FILE}) { save_file(); } else { save_as(); } } sub save_as { my $file_name = $main::self->{MAIN_WINDOW}->getSaveFile(); if ($file_name ne "") { $main::self->{OPEN_FILE} = $file_name; save_file(); display_file_name(); } } sub open_file { if ($main::self->{OPEN_FILE} = $main::self->{MAIN_WINDOW}->getOpen +File()) { open(FILE, "<", $main::self->{OPEN_FILE}); local $/; my $program = <FILE>; close(FILE); $main::self->{PROGRAM_TEXT}->delete("1.0", "end"); $main::self->{PROGRAM_TEXT}->insert("end", $program); display_file_name(); } } sub new_file { $main::self->{OPEN_FILE} = undef; $main::self->{PROGRAM_TEXT}->delete("1.0", "end"); display_file_name(); } sub display_file_name { if ($main::self->{OPEN_FILE}) { $main::self->{MAIN_WINDOW} ->configure("title", "My Porgram - $main::self->{OPEN_FILE}" +); } else { $main::self->{MAIN_WINDOW} ->configure("title", "My Porgram - Untiled"); } }

In reply to perl IDE in perl by pg

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.