Well this is a shortcut I use all the time, to setup a Perl script. I use midnight commander for almost all my work, and it has a "template menu" which you can invoke in the editor to add template code. This one lets you "touch filename" ( I have touch bash-aliased to just 't' :-) ), then hit F4 to edit the empty new file, then F11 to get a selection of templates. Then hit 'p' to insert the basic perl template.

In /usr/share/mc/cedit.menu

+ y unknown & t r p #!/usr/bin/perl echo "#!/usr/bin/perl use warnings; use strict; " >%b
I also have extended it to make a basic gtk2 app with the 'h' key
+ y unknown & t r h #!/usr/bin/perl echo "#!/usr/bin/perl use warnings; use strict; use Glib qw/TRUE FALSE/; use Gtk2 '-init'; my \$window = Gtk2::Window->new('toplevel'); \$window->set_title('Z'); \$window ->signal_connect( 'destroy' => \\&delete_event +); \$window->set_border_width(10); \$window->set_size_request(300,200); my \$vbox = Gtk2::VBox->new( FALSE, 6 ); \$window->add(\$vbox); \$vbox->set_border_width(2); my \$hbox= Gtk2::HBox->new( FALSE, 6 ); \$vbox->pack_end(\$hbox,FALSE,FALSE,0); \$hbox->set_border_width(2); my \$frame0 = Gtk2::Frame->new('Controls'); \$vbox->pack_end( \$frame0, FALSE, FALSE, 0 ); \$frame0->set_border_width(3); \$vbox->pack_end (Gtk2::HSeparator->new, FALSE, FALSE, 0 +); my \$hbox0 = Gtk2::HBox->new( FALSE, 6 ); \$frame0->add(\$hbox0); \$hbox0->set_border_width(3); my \$button = Gtk2::Button->new_from_stock('gtk-quit'); \$hbox0->pack_end( \$button, FALSE, FALSE, 0 ); \$button->signal_connect( clicked => \\&delete_event ); \$window->show_all(); Gtk2->main; ##################################### sub delete_event { Gtk2->main_quit; return FALSE; } " >%b

I'm not really a human, but I play one on earth. flash japh

In reply to Re: Contribute a hack to the new "Perl Hacks" book by zentara
in thread Contribute a hack to the new "Perl Hacks" book by Ovid

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.