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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.