Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Confession of a hard headed Monk

by sundialsvc4 (Abbot)
on May 12, 2017 at 00:04 UTC ( #1190107=note: print w/replies, xml ) Need Help??


in reply to Confession of a hard headed Monk

The default behavior of this subroutine is to return a word number not an integer.

So why, exactly, are you now arguing against yourself ... even, “calling yourself ‘a doofus™”” ... with regards to a software solution that apparently works?

Replies are listed 'Best First'.
Re^2: Confession of a hard headed Monk
by Lady_Aleena (Curate) on May 12, 2017 at 17:39 UTC

    Just because something works does not mean it is useful, good, or right. There are very few people would find a number as a word useful, but an integer is very useful. So making the return of an integer the default might lead to a few people using this little subroutine possibly. I've given an example below of what it does, and to show why it is more useful to return an integer by default.

    use Util::Columns; my @list = <DATA>; chomp @list; my $columns = get_columns(7, \@list); # why take another step to get a +n integer? # If you don't add 1 to the result of the division below, # you will get an additional column. my $splicer = (scalar(@list) / $columns) + 1; my $row; push @$row, join("\n", splice(@list, 0, $splicer)) while @list; # then print the row however you like

    This is what I got from a list of html elements. If the list had fewer than 49 items, the there would have been 6 columns. (I have been working a lot with html elements lately, so they are on my mind.)

    <a> <code> <fieldset> <img> <object> <sect +ion> <tfoot> <abbr> <col> <figcaption> <input> <ol> <sele +ct> <th> <address> <colgroup> <figure> <ins> <optgroup> <shad +ow> <thead> <area> <content> <footer> <kbd> <option> <slot +> <time> <article> <data> <form> <label> <output> <smal +l> <title> <aside> <datalist> <h1> <legend> <p> <sour +ce> <tr> <audio> <dd> <h2> <li> <param> <span +> <track> <b> <del> <h3> <link> <pre> <stro +ng> <u> <base> <details> <h4> <main> <progress> <styl +e> <ul> <bdi> <dfn> <h5> <map> <q> <sub> + <var> <bdo> <dialog> <h6> <mark> <rp> <summ +ary> <video> <blockquote> <div> <head> <menu> <rt> <sup> + <wbr> <br> <dl> <header> <menuitem> <rtc> <tabl +e> <button> <dt> <hgroup> <meta> <ruby> <tbod +y> <canvas> <element> <hr> <meter> <s> <td> <caption> <em> <html> <nav> <samp> <temp +late> <cite> <embed> <i> <noscript> <script> <text +area>
    No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
    Lady Aleena

      Just and FYI, you're replying to someone with a track record of terrible advice and frankly nonsense postings.

        "...terrible advice and frankly nonsense postings."

        For sure. But why are there still some folks that up vote his junk?

        Regards, Karl

        «The Crux of the Biscuit is the Apostrophe»

        Furthermore I consider that Donald Trump must be impeached as soon as possible

      Bad, bad, bad logic in a part of the usage code I provided above...

      # If you don't add 1 to the result of the division below, # you will get an additional column. my $splicer = (scalar(@list) / $columns) + 1;

      It should be...

      # Add 1 to the result of the division below # if list is not evenly divisible by $columns. my $splicer = int(scalar(@list) / $columns); $splicer += scalar(@list) % $columns > 0 ? 1 : 0;

      Sorry for not thoroughly testing that part. 8(

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena
        Which can be shortened to
        my $splicer = int(@list / $columns) + (@list % $columns > 0);

        ($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
Re^2: Confession of a hard headed Monk
by Anonymous Monk on May 12, 2017 at 17:51 UTC
    Because "works" is merely the beginning. You also need to address the following:
    1. User experience
    2. Availability
    3. Performance
    4. Scalability
    5. Adaptability
    6. Security
    7. Economy
    I applaud any effort to improve the skills to fulfill these requirements.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1190107]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2019-12-08 18:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?