For a non-"SELECT" statement, "execute" returns the
number of rows affected, if known. If no rows were
affected, then "execute" returns ""0E0"", which Perl
will treat as 0 but will regard as true. Note that it is
not an error for no rows to be affected by a statement.
If the number of rows affected is not known, then
"execute" returns -1.
This is Sybase, and I want to run the query repeatedly adjusting tmpDate in temporary table #LAG until none of them fall on holidays for the particular country. But, this code loops forever, as when there are no more rows, do returns "0E0".while (my $rows = $dbh->do(<<SQL)) { update #LAG set tmpDate = dateadd( day, case when datepart( weekday, cl.tmpDate) = 2 then -3 else - +1 end, cl.tmpDate) from #LAG cl, $db..HOLIDAY h where cl.tmpDate = h.Date and cl.country = h.country SQL print "$rows holidays adjusted\n"; }
I know that this subject has been covered before on PM, see Should string inequality operators return the point the of divergance? and What is truth? (Curiosity corner).
I also recall that the return value of the flip-flop operator .. in scalar context has "E0" appended to signal a terminating match. On some levels, I think that this is very clever, as this is interpreted by perl's string to number parser as "X 10 to the power 0". Hence, using this scalar value in numeric context gives you the line count.
I have several questions in my mind:
Update: I realise with hindsight that I hadn't made it clear that I had solved the original problem. This is the reason it was posted as a meditation, not SOPW.
--
I'm Not Just Another Perl Hacker
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: The Naughty Nought "OEO" blues
by merlyn (Sage) on Jan 20, 2005 at 17:35 UTC | |
|
Re: The Naughty Nought "OEO" blues
by demerphq (Chancellor) on Jan 20, 2005 at 17:02 UTC | |
by tye (Sage) on Jan 20, 2005 at 17:27 UTC | |
by demerphq (Chancellor) on Jan 20, 2005 at 17:29 UTC | |
|
Re: The Naughty Nought "OEO" blues
by mpeppler (Vicar) on Jan 20, 2005 at 18:46 UTC | |
|
Re: The Naughty Nought "OEO" blues
by thor (Priest) on Jan 20, 2005 at 16:53 UTC | |
|
Re: The Naughty Nought "OEO" blues
by borisz (Canon) on Jan 20, 2005 at 17:41 UTC |