You (azaragoza) wrote:
When I run the code instead of returning something like, SERVICE_START_PENDING, it returns a zero or a one. Thanks for your help.

SERVICE_START_PENDING and the other CAPitalized items are capitalized because they are constants. They are preprocessor macros that are defined in the C/C++ API for the MS Windows systems under discussion.

Perl customarily uses a convention to represent such preprocessor macros. Since Perl isn't C or C-like, it does not use a preprocessor. Instead, these tokens are exported from the module as constant subroutines, ones which have names that are in all-caps. See the constant.pm documentation. A constant subroutine is syntactically a subroutine but it always returns the same value (and so the Perl parser, which is a very smart parser, reduces the subroutine call to a simple constant in the compilation phase).

You have been suitably punished for not using strict; in your code, and will go on being punished in many others ways as long as you reject or forget this basic level of Perl wisdom (punished by not being told by Perl that you were saying something nonsensical; your constants were being seen as barewords that were interpreted as sloppy unquoted strings because you neglected strict). If you had used strict you would have seen that some subroutines were undefined and therefore compilation was aborted.

This satisfying form of Instance Justice (to quote Damian Conway) is visited on Perl users who try to get by with merely emulating what they think is the code needed to use a sophisticated interface module - faking it IOW - instead of getting serious and doing things the smart way at each level, from simple and basic like "use strict; use warnings;" to each level upwards in complexity and specialization. To do things the smart way you have to study and learn what the smart way is, and then put it into practice in each piece of code you write. You have to learn Perl in other words.

HTH

    Soren Andersen / “somian” / “perlspinr”


In reply to Re: Win32::Daemon::State returns a 0 or 1 by Intrepid
in thread Win32::Daemon::State returns a 0 or 1 by azaragoza

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.