Tony Heal wrote:
>
OK I am probably missing something stupid, but I can not get this to work.
The output should be 'Daily-{day of week)-{MMM}-{DD}-{YYYY}' for Sunday
thru Friday and 'Weekly-{1|2|3}-{day of week)-{MMM}-{DD}-{YYYY} for
Saturday and every fourth Saturday should start rotating months
'Month-{1|2|3}-{day of week)-{MMM}-{DD}-{YYYY}

Anyone got any ideas?

Oh, there is some code at the front that changes the system date from May 1
to 31

Hi Tony

I'm sorry I'm afraid there's so little chance of getting that code working I'm
not even going to try. I spent half an hour trying to understand how it was
structured and what you were trying to do and had to give up. It looks to me
like you've written the whole thing in one go and then started to get it to
work, which isn't the way to go about even simple coding problems: you need to
make software work in small steps at a time and gradually approach the final
solution, all the time with a working partial solution.

To try and get you started here are a few pointers, with most of the code
removed so that the problems are apparent:

You have written

  while ($count lt 532){

    my $backupDir = gfsBackup();

    sub gfsBackup

    }

  $count++;}


which I didn't even know would compile. Take the subroutine out of the while
loop or there's really no point in having it there.

Oh, and it should be

  while ($count < 532) {
  }

otherwise you're comparing text instead of numbers.


The lines

  opendir (DIR, $backupBaseDir);
  my @readdir = readdir(DIR);
  closedir(DIR);

  while (<@readdir>)
  {
  }

are wrong, and the most obvious fix is to put

  foreach (@readdir) {

  }

but I don't know if the code around this will work either way.


You have

  if ( $days[$wday] =~ "Saturday" )
  {
  }
  elsif ( $days[$wday] =~ "Saturday" )
  {
  }

which is clearly wrong, and it isn't obvious what you meant. Furthermore these
two conditional lines are indented by different amounts, making me think your
nesting isn't what you think it is. Use less whitespace in your code and
carefully align matching braces.

Finally, stuff like

  if ($days[$wday] =~ "Saturday")

should be

  if ($days[$wday] eq 'Saturday')

although this won't actually stop it working.

I think that's all I can do for you for now. Please try to clarify your code
and make it look as if it ought to work before you try it. You are doomed to
failure if you throw together a few approximate source lines and try to hack
them until the output looks right.

Good luck,

Rob


--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/


Reply via email to