Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Never say never

by Lady_Aleena (Curate)
on May 06, 2015 at 03:37 UTC ( #1125791=perlmeditation: print w/replies, xml ) Need Help??

A thud can be heard throughout the monastery as Lady Aleena's head hits her desk in the scriptorium. Shortly thereafter the sound of breaking glass filters through the monastery's halls as her preconceptions are shattered.

Never say you will never do a thing because, one day, you will do the thing then feel foolish.

Now here is some history and what happened tonight. I said I would never use pipes in my data fields. Tonight I did. Now I am feeling more than foolish. (And I've made more work for myself while trying to make less work for myself.) I just learned my lesson.

If you feel you are about to say "I will never...", stop, think very hard, count to ten, whatever. Just do not say it! One day you will be writing a piece of code, humming a little tune stuck in your head, then you will crash into a wall because you did not take into consideration the exception you just wrote.

Have a nice day!

I started this thought in the CB and continued it here.

No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
Lady Aleena

Replies are listed 'Best First'.
Re: Never say never
by Not_a_Number (Prior) on May 06, 2015 at 16:57 UTC

    I'm afraid I don't get this (maybe because I'm not an avid follower of the CB?). Why on earth should one not want to put pipes in a data field? Unless, of course the fields themselves are pipe-separated...

    \|   # <- Ceci n'est pas une pipe

    Update: Just to be clear: my post was not meant to be taken as Lady Aleena bashing (which, BTW, seems to be the preserve of Anonymous Monk). Rather, it was meant to be a request for some context:

    From the OP:

    I said I would never use pipes in my data fields. Tonight I did. Now I am feeling more than foolish. (And I've made more work for myself while trying to make less work for myself.) I just learned my lesson.

    For me, this makes little or no sense out of context. Context that was presumably present in the Chatterbox ('I started this thought in the CB'). Context that should be provided in this thread, in order to make sense of it and to make the OP worthy of Meditations status.

      I think that is the point of the post. The problems come in when you think "Why would you ever want to put X in the data?".

      Thinking "Why would you ever NOT want to (have the option to) put X in the data?" is safer.

      PS: ++ for the !|

      Not_a_Number, sorry, I didn't want to get into the deep dark in my OP.

      A long long time ago, I decided to use pipe separated file to store some of my data. I wrote a little subroutine which would process those files. Everything was good up until last night.

      Last night I was rewriting a group of modules and scripts. A few of my data fields were several paragraphs each (making my data file scroll far off to the right as you can imagine). I decided to process those paragraphs with another subroutine I wrote a while ago, however, it would destroy HTML tags in the paragraphs. I needed to use another home rolled format to insert the tags. I had several HTML anchors in the text, so my home rolled way to show them looks akin to A<some text|href="http://some.link.com">. Now, you see the pipe in the tag? My subroutine which processes my data files was splitting the line at that pipe too.

      Now, I initially chose to use pipe separated files because I did not think to the future where I would use pipes inside a data field. I did not have the home rolled tag parser when I made the decision nor was it even in mind at the time.

      I tried to keep the OP clean of this deep dark history. It appears trying to be general has bitten me. I did not want this thread to turn into a discussion of my coding practices. I was just thinking of how I should not have said "I would never...", and how others should not get into that kind of thinking either about a little thing.

      Just because you are not doing it today and do not have plans to do it tomorrow does not mean you will not to it the day after next. I just wanted to impart that piece of wisdom with as little drama as possible.

      Most of what I have discussed up here is in a node somewhere else on PM. The subroutine I use to parse my data files is on my home node under "The present: Objects". The paragraph parser was discussed in 1059065 and 1062854 (discuss here if you wish). The home rolled tag parser was discussed in 1028657 and 1107051 (discuss here if you wish). I do not know if any of them need further discussion, they work.

      I hope I have provided enough context. Going into it anymore would be going into the pitch black deep dark. I try not to go there often due to how unpopular my code is in some corners of the monastery.

      No matter how hysterical I get, my problems are not time sensitive. So, relax, have a cookie, and a very nice day!
      Lady Aleena
        "I just wanted to impart that piece of wisdom with as little drama as possible."

        Would this happen to be the "wisdom" of developing without tests?
Re: Never say never
by Anonymous Monk on May 06, 2015 at 15:40 UTC
    "Never say never" means "nothing is impossible, anything can happen." This is very common knowledge.

    You have a lot of misconceptions about how split works:

    perldoc -f split split /PATTERN/,EXPR,LIMIT
    The first argument is a regular expression. Pipes are metacharacters in regular expressions. You have to escape them if you want to match a literal representation of this.
    perldoc perlre In particular the following metacharacters have their standard egrep-ish meanings: \ Quote the next metacharacter ^ Match the beginning of the line . Match any character (except newline) $ Match the end of the string of the string) | Alternation () Grouping [] Bracketed Character class

    The reason why you make more work for yourself rather than less is not because you went back on some hyperbolic rules you literally interpreted and placed upon yourself, but because you lack understanding of the tools you are using. I don't see how you are qualified to give advice to professionals who do this for a living.

      "Never say never" means "nothing is impossible, anything can happen." This is very common knowledge.

      "Never say never" means there is usually an exception, you don't know what the future will bring, and you may be unaware of the potential of others. However, it does not mean "nothing is impossible." Some things are.

      I don't see how you are qualified to give advice to professionals who do this for a living.

      You completely missed the point. The point is "Never say never." Regardless of where or why, this is a good rule of thumb for everyone.

        Anonymonk is rancorous today which is uncool and unproductive but not wrong in spirit.

        Regardless of where or why, this is a good rule of thumb for everyone.

        The reason Im here every day instead of Facebook is the lack of platitudes and aphorisms except where it might directly help me work with code design, execution, debug, test, process, etc I like everyone getting along, I like OT posts, I like being genial and insult free, but the CB is the place for this kind of thing. I am surprised an OP with no code content and misleading advice implied can gain so many upvotes. Then again, Im surprised that some of my more absurd comments here get upvotes too. :P

        Update: inserted a preposition, erix!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://1125791]
Approved by kcott
Front-paged by Old_Gray_Bear
help
Chatterbox?
[sierpinski]: thanks LanX that helps
[haukex]: the first index is always 0 - $#array gives you the last index in @array
[sierpinski]: gotcha, thanks
[LanX]: length = last index +1

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (16)
As of 2017-12-13 16:03 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (369 votes). Check out past polls.

    Notices?