[27011] in Perl-Users-Digest

home help back first fref pref prev next nref lref last post

Perl-Users Digest, Issue: 8940 Volume: 10

daemon@ATHENA.MIT.EDU (Perl-Users Digest)
Fri Feb 10 14:05:51 2006

Date: Fri, 10 Feb 2006 11:05:08 -0800 (PST)
From: Perl-Users Digest <Perl-Users-Request@ruby.OCE.ORST.EDU>
To: Perl-Users@ruby.OCE.ORST.EDU (Perl-Users Digest)

Perl-Users Digest           Fri, 10 Feb 2006     Volume: 10 Number: 8940

Today's topics:
    Re: Program to generate buttons for sequence of command <zentara@highstream.net>
    Re: Typos, was  Perl vs. Python <scobloke2@infotop.co.uk>
        Digest Administrivia (Last modified: 6 Apr 01) (Perl-Users-Digest Admin)

----------------------------------------------------------------------

Date: Fri, 10 Feb 2006 15:14:02 GMT
From: zentara <zentara@highstream.net>
Subject: Re: Program to generate buttons for sequence of commands
Message-Id: <k8bpu1p3ll108b91n4vlkliqphmgjou1rv@4ax.com>

On Thu, 9 Feb 2006 14:57:49 +0000 (UTC), rgompa@steel.ucs.indiana.edu
(Raghuramaiah Gompa) wrote:

>
>I am new to perl.  I am trying to write a code, runme.pl, 
>to 
>generate 16 buttons in 4 rows and 4 colums.  Each button 
>will be associated with a sequence of commands.  For 
>examle, after perl runme.pl test, when pressed the first 
>button, it should execute:
>
>latex test.tex
>dvips test.dvi
>gview test.ps
>
>(This is similar to TeXorg, if you know this.  But 
>this will have a sequence of commands for each button 
>- not just one command.) Will you please help me get 
>started?  Is this possible?

Here is a basic demo, making it look even is up to you.

#!/usr/bin/perl
use warnings;
use strict;
use Tk;

my $mw = tkinit;
#$mw->geometry("400x400");
my $rF = $mw->Frame( -width => 400 )->grid;

my %buttons;

my %commands = (
      '1-1' => {text => 'Date', com =>'date', color=> 'pink'},
      '1-2'   => {text => 'ls', com => 'ls -la', color => 'lightblue'},
      '1-3' => {text => 'Date', com =>'date', color=> 'pink'},
      '1-4'   => {text => 'top', com => 'ls -la', color => 'lightblue'},
      '2-1'  => {text => 'ps', com =>'date', color=> 'pink'},
      '2-2'   => {text => 'ls', com => 'ls -la', color => 'lightblue'},
      '2-3' => {text => 'Dateyada', com =>'date', color=> 'pink'},
      '2-4'   => {text => 'lsfoobar', com => 'ls -la', color =>
'lightblue'},
      '3-1' => {text => 'Datexxxx', com =>'date', color=> 'pink'},
      '3-2'   => {text => 'lsccc', com => 'ls -la', color =>
'lightblue'},
      '3-3' => {text => 'Datebbbb', com =>'date', color=> 'pink'},
      '3-4'   => {text => 'lsnnn', com => 'ls -la', color =>
'lightblue'},
      '4-1' => {text => 'Date777', com =>'date', color=> 'pink'},
      '4-2'   => {text => 'ls777', com => 'ls -la', color =>
'lightblue'},
      '4-3' => {text => 'Dategggcom', com =>'date', color=> 'pink'},
      '4-4'   => {text => 'lsgggcom', com => 'ls -la', color =>
'lightblue'},
);


foreach my $key(keys %commands){
   my ($i, $j) = split /-/,$key;
   $buttons{$key}{'button'} = $rF->Button(
                    -text => $commands{$key}{'text'},
             -background  => $commands{$key}{'color'},
		 -command => sub{ &launch( $key )  }
                 )->grid(-row=>$i, -column=> $j );
}

MainLoop;

sub launch {
   my $key = shift;
   my $command = $commands{$key}{'com'};
   if(fork==0){ exec "xterm -hold -e $command"   }

}
__END__


-- 
I'm not really a human, but I play one on earth.
http://zentara.net/japh.html


------------------------------

Date: Fri, 10 Feb 2006 17:08:53 +0000 (UTC)
From: Ian Wilson <scobloke2@infotop.co.uk>
Subject: Re: Typos, was  Perl vs. Python
Message-Id: <dsihb5$idp$1@nwrdmz01.dmz.ncs.ea.ibs-infra.bt.com>

Patrick M. Rutkowski wrote:
> I made two type-o's that were hopefully self evident:

Since you've raised the subject:

"typo" is an abbreviation of "typographical error".

> 
>  >> "I'm currently learning Perl from the Camel Book"
> I meant Lama Book

Llama.

;-)


------------------------------

Date: 6 Apr 2001 21:33:47 GMT (Last modified)
From: Perl-Users-Request@ruby.oce.orst.edu (Perl-Users-Digest Admin) 
Subject: Digest Administrivia (Last modified: 6 Apr 01)
Message-Id: <null>


Administrivia:

#The Perl-Users Digest is a retransmission of the USENET newsgroup
#comp.lang.perl.misc.  For subscription or unsubscription requests, send
#the single line:
#
#	subscribe perl-users
#or:
#	unsubscribe perl-users
#
#to almanac@ruby.oce.orst.edu.  

NOTE: due to the current flood of worm email banging on ruby, the smtp
server on ruby has been shut off until further notice. 

To submit articles to comp.lang.perl.announce, send your article to
clpa@perl.com.

#To request back copies (available for a week or so), send your request
#to almanac@ruby.oce.orst.edu with the command "send perl-users x.y",
#where x is the volume number and y is the issue number.

#For other requests pertaining to the digest, send mail to
#perl-users-request@ruby.oce.orst.edu. Do not waste your time or mine
#sending perl questions to the -request address, I don't have time to
#answer them even if I did know the answer.


------------------------------
End of Perl-Users Digest V10 Issue 8940
***************************************


home help back first fref pref prev next nref lref last post