Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

In many cases, yes, you are right. But in this case, at least in my opinion, the usage is quite clear. The switch could either be on (1) or off(0) or we don't know yet (-1 = number that could never happen otherwise). And i even bothered to document it:

my $lastswitch = -1;

The whole $lastswitch thing could just be set to 0 on startup in theory (guessing the button isn't pressed on startup). Or i could just replicate the Device::BCM2835::gpio_lev($testpinnumber) call at the beginning.

I just kept this one-off script for my one-off device to my usual style guide of 15+ years of Perl coding. If i see that construct, i instantly know i'm dealing with an uninitialized boolean. Same goes for other "magic" numbers. 3600 is seconds per hour, 86400 is seconds per day and 365.25 is (average) days per year.

Those kinds of magic numbers i wouldn't call "bad", it's more of a grey area.

I can completely understand your point of view, and in most cases i'd support you all the way, but i hereby invoke my right of TIMTOWTDI 😉

perl -e 'use MIME::Base64; print decode_base64("4pmsIE5ldmVyIGdvbm5hIGdpdmUgeW91IHVwCiAgTmV2ZXIgZ29ubmEgbGV0IHlvdSBkb3duLi4uIOKZqwo=");'

In reply to Re^2: Implementing a 2-mode "Audiobutton" on the Raspberry Pi by cavac
in thread Implementing a 2-mode "Audiobutton" on the Raspberry Pi by cavac

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, 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, 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.
  • Log In?

    What's my password?
    Create A New User
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others avoiding work at the Monastery: (3)
    As of 2021-04-11 08:03 GMT
    Find Nodes?
      Voting Booth?

      No recent polls found