The UNIX and Linux Forums  
Hello and Welcome from to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
.
google unix.com



Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts and shell scripting languages here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
issue with if loop in perl amitrajvarma Shell Programming and Scripting 4 01-09-2008 12:02 AM
loop throw perl regexp selection umen Shell Programming and Scripting 6 08-28-2006 11:35 AM
how to get the pos() of 2 str matches in one loop in perl umen Shell Programming and Scripting 1 07-26-2006 10:30 AM
Perl - Iterating a hash through a foreach loop - unexpected results quantumechanix Shell Programming and Scripting 5 12-15-2003 07:08 PM
for loop using the value '01' in PERL dangral Shell Programming and Scripting 9 10-01-2003 04:34 PM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 04-07-2002
methos methos is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 18
help with perl while loop

Can anyone tell me why this program won't kick out when the time gets beyond time in the loop?

sub showtime
{
local($format,$military)=@_;
($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);

if ((! $military) && ($hour > 12)) {$hour-=12;}
$min=sprintf("%02d",$min);
$sec=sprintf("%02d",$sec);
$format =~ s/SS/$sec/g;
$format =~ s/HH/$hour/g;
$format =~ s/MM/$min/g;
return $format;
}
printf &showtime("The Time is Now HHMM\n",1);
while ($showtime le 2345)
{
while ($x==0 )
{
if (-e $legrun)
{
$x=0;
sleep 10;
}
else
{
$x=1;
}
}
$x=0;
  #2 (permalink)  
Old 04-08-2002
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
As far as I can see the variable $legrun appears only once in your script, so the statement:

if ( -e $legrun) {
...

will never be true. You should define the filename before you check for its existance.
  #3 (permalink)  
Old 04-08-2002
methos methos is offline
Registered User
  
 

Join Date: Jan 2002
Posts: 18
I figured it out, it was actually because I was not formatting showtime

while (&showtime(HHMM, 1) < 1422)


Thanks
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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 On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 01:16 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0