Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
I perfectly know that dbwiz gave a good advice, as you can note in Re^5: what is the best way to seperate the digits and strings from variable ?. I only argued upon his jumping to conclusions pointing out that he was working under assumptions that were different from mine, and he basically made my very same error: thinking in a restricted context.

And, jokes apart, I'm not fooling myself (even if you may think I'm trying to fool you); I'd like to see a single post of mine in which I was even slightly erroneous without taking my responsabilities. If you find, please point me out.

If you read my answer carefully, you'd see that:

  • I thought about what I was writing, maybe for the very single time;
  • dbwiz suggestion was based upon the assumption that the OP wanted to extract a number. I was answering to a question that dealt with a string. We can argue about that at will, but the fact remains that we were talking about different things and that my answer applied to what I was talking about. Incidentally, the OP language seems to be biased towards my interpretation, at least in my understanding - but here I'm repeating myself.
On with the rest:
Assigning $1 without testing is almost a capital sin in Regex parlance
This is like saying that I shouldn't use symbolic references. Why not, if they're in a controlled environment? As dbwiz correctly noted, my regex ALWAYS matches, because it matches the empty string. So, why should I check if $1 is set if I already know that it's set? Just because otherwise I'm committing a capital sin?
Your initial code would pass a test against the only example provided by the OP
I'm happy that you noticed, because I clearly stated that the question was not clear. On the other side, I completely disagree on the following consideration:
but it would fail in many other cases.
Of which you provide no single example. And I can tell you why: you continue to assume that you have to extract numbers, and I continue to say that we could need digits. What if he wanted to swap the digit and alpha parts? Would you accept to move files:
0001-ciccio.txt 001-ciccio.txt 01-ciccio.txt
all to ciccio-1.txt?

To definitively conclude this mess:

  • I hereby state that I thank dbwiz for his pointing out that I'm a moron who'd better think about all possible context in which his answers could be used
  • I'm stopping this thread here. Sorry, I don't like it any more and I like much less to repeat myself. I accepts my limits in expressing myself, unluckily I'm Italian and English is not my primary language.
  • I ask pardon to all who've been bored by my posts in this thread.
  • I invite all, me first, to consider that there can be other points of view, and that the discussion should be open enough to benefit from them all without excluding any a-priori.
Cheers
Cin-cin with our beer pints! (or whatever you like to drink)

Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')

Don't fool yourself.

In reply to Re^5: what is the best way to seperate the digits and strings from variable ? by polettix
in thread what is the best way to seperate the digits and strings from variable ? by swaroop

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!
  • 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?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others examining the Monastery: (5)
    As of 2015-07-05 04:35 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









      Results (60 votes), past polls