Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

As ww says, nicely done! A couple of minor points:

  1. In sub DrawSegment{, the line:

    elsif($segment = 6) { # Draw the 6 sided segment(6)

    is almost certainly a mistake: it sets $segment to the value 6, which is “true”, so the following else block will never be reached. Replace = with ==.

  2. A subroutine such as:

    sub GetValue{ my $return = $wxGlobals{mValue}; }

    would be better written as:

    sub GetValue{ return $wxGlobals{mValue}; }

    as the lexical variable $return serves no purpose here — it is being created and initialised only to be immediately thrown away. Likewise, this:

    sub Decode { # Table lookup for character t +o my($char) = @_; # Segment translation my $return; if(defined($ctbl{$char})) { $return = $ctbl{$char}; } else { $return = $ctbl{'='}; # Triple bar for undefined cha +racter } }

    works, but only (in a sense) by accident: the last expression evaluated will be an assignment to $return, so the value assigned will be returned by the sub. But with a small code change, this logic could easily break. Simpler, safer, and clearer:

    sub Decode # Table lookup for character t +o segment translation { my ($char) = @_; if (defined $ctbl{$char}) { return $ctbl{$char}; } return $ctbl{'='}; # Triple bar for undefined cha +racter }

    Update: ++BrowserUk for the much better version below!

Hope that helps,

Athanasius <°(((><contra mundum Iustus alius egestas vitae, eros Piratica,


In reply to Re: wxPerl Simulated 7 Segment LCD Display by Athanasius
in thread wxPerl Simulated 7 Segment LCD Display by jmlynesjr

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-20 08:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found