From: Rick D. <ri...@de...> - 2004-06-30 16:07:14
|
On Wed, 2004-06-30 at 09:19 +0100, MH wrote: > Robin, > > I think you're missing another 'and' - > > If we want dial AND > (it's Friday or Saturday) AND > it's less than 10PM > > Gotta watch those AND/OR combinations, always bracket them to make sure of > what's happening... > > So we get something like... > > if ( said $rv_dialup eq "Start" and > ($Day eq "Fri" or $Day eq "Sat") and > time_less_than("10:00PM") > ) { I don't think that this is exactly what the original poster wanted, which, if I understand correctly was to limit the kids access to the internet after 10 pm on school nights, and to allow it at anytime on Friday and Saturday nights. Another way of saying this is we want to allow access if it's Friday or Saturday or it's before 10 PM. Here's a more perlish* (albeit untested) way of doing that using pattern matching for the day of the week test. if (said $rv_dialup eq "Start" and ($Day =~ /^(Fri|Sat)/ # It's not a school night if $Day # starts with either "Fri" or "Sat" or time_less_than("10:00PM"))) { # Start the internet } *Keep in mind that one of the perl mantras is TMTOWTDI (There's More Than One Way To Do It), however pattern matching is one of the fundamental paradigms of perl. |