Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Comment on

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

I personally believe that

  • a "better" s-based solution was already posted by jwkrahn, in particular:
  • there's no need to match a 1 at the end of the string, and avoiding to do so could generalize the code to spit out the sequence to begin with zero 1's - not that anybody requested it, but it's such a tiny violation of YAGNI for both a simpler syntax and added flexibility that I would only avoid it if it were expressedly ruled out;
  • we recommend not to use $a and $b as general purpose variables all the time, which would be especially important here, given that the OP is clearly a newbie;
  • this thread is clearly facetious in many ways, but as a general programming rule, it's awkward and error prone that you somehow unnecessarily duplicate information, holding it in two variables where one would suffice: namely in $a as the length of $a itself and in $b as an integer, whereas the two quantities are fundamentally the same. Once you use only one variable, perhaps taking advantage of $_ to use smart defaults, and switching to the while statement modifier, your code could be morphed into:
perl -le 's/$/1/, print while 100 > length'

Incidentally, now that I notice, the anchor is not necessary at all. If it were not for a mandatory /e modifier, this could make for a golfed solution just as good as JavaFan's

perl -E'{s//say/e,redo}'

but that's not the case...

--
If you can't understand the incipit, then please check the IPB Campaign.

In reply to Re^2: Generate the perl sequence 1, 11, 111, .... by blazar
in thread Generate the perl sequence 1, 11, 111, .... by alih110

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, 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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    [marto]: good morning all
    [Corion]: Hi marto!
    [Corion]: The fun show at $work continues, as The Big Project is now in its second week of frantic live-bugfixing and weekend releases where nobody knows what went live. Nothing has been tested anyway.
    erix mutters cantankerously under his breath
    Corion watches from the sidelines. Or rather, from behind, as my system only gets output from that process and my programs adhere strictly to the GIGO design principle.
    [erix]: ah, that's nice to hear Corion :)
    [Corion]: erix: Yeah, the sad thing is that all I can do is document things, so I can point fingers when the auditors come :-/
    [Corion]: "I'm here to open tickets and point fingers. And I'm all out of tickets."
    [erix]: didn't Sybase have pretty good auditing? :) (this is a vague memory)
    [erix]: (culprits often are upstream of db of course)

    How do I use this? | Other CB clients
    Other Users?
    Others meditating upon the Monastery: (7)
    As of 2017-03-28 08:57 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?
      Should Pluto Get Its Planethood Back?



      Results (328 votes). Check out past polls.