LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-18-2009, 01:06 PM   #1
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Rep: Reputation: 36
looping a dialog box in perl


Hello people,

I Need a small help in creating a loop in perl. My task is to print the current time on a zenity dialog box.Is there any way i can make the time being display on the dialog box in real time? Something like tailf or watch command?

Quote:
#!/usr/local/bin/perl -w
use strict;
use warnings;
my $i=2;
until ($i==1)
{
my $a = `date +\%H:\%M:\%S`;
`zenity --info --text $a`;
}
The problem is i need to press the ok button on the dialog box so as to dialog box to load again with the refreshed time.Can i in anyway automate it,with out any human interaction? Sorry if this Question doesnt make sense

Thanks.
 
Old 09-19-2009, 07:08 AM   #2
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Original Poster
Rep: Reputation: 36
Ok can any one tell me how to kill that dialog box in the code itself?
 
Old 09-19-2009, 02:55 PM   #3
kdelover
Member
 
Registered: Aug 2009
Posts: 311

Original Poster
Rep: Reputation: 36
any help
 
Old 09-19-2009, 03:42 PM   #4
slakmagik
Senior Member
 
Registered: Feb 2003
Distribution: Slackware
Posts: 4,113

Rep: Reputation: Disabled
I don't know perl, but it seems to me that you've set a variable i to have the value of 2 and then set up your loop to terminate when i is equal to 1, but you never change the value of the variable. Something like

Code:
#!/usr/local/bin/perl -w

use strict;
use warnings;

my $i=2;

until ($i==1)
{
    my $a = `date +\%H:\%M:\%S`;
    `zenity --info --text $a`;
    $i--;
}
would decrement $i and cause the loop to exit after one iteration. Maybe if you explained more clearly what you were trying to do (why loop, how many times intended, etc.) more people could help. Also, your phrase "my task" makes it sound like homework, which may be discouraging folks from replying. And code blocks should be in 'code' tags rather than 'quote'. Hope some of this helps.

Last edited by slakmagik; 09-19-2009 at 03:44 PM. Reason: so if we are going to use a code block, let's space and indent ;)
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
ncurses dialog box mlangdn Slackware 7 06-03-2009 09:22 PM
looping an array to populate menu for "dialog" kushalkoolwal Programming 4 01-30-2009 02:20 AM
qt3 and dialog box text binarybob0001 Programming 1 11-18-2007 09:15 PM
Dialog box help!!!!!!!! HopelessLinuxNewbie Fedora 1 08-24-2005 11:48 AM
Dialog box scripting.... r_jensen11 Programming 2 01-25-2004 06:40 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 08:24 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration