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

Re: Formatting Strings Without Interpolating Whitespace

by TomDLux (Vicar)
on Jan 20, 2012 at 03:13 UTC ( #948875=note: print w/replies, xml ) Need Help??

in reply to Formatting Strings Without Interpolating Whitespace

Why do you want to specify newlines explicitly as \n? If you are generating a significant document, why are the strings even part of the code file? Separate the text from the code and you can send out different languages; your designers can rearrange the message with insignificant change to the program.

Put message snippets into separate text files, if you need various options, laid out exactly as you want it to look. If you want to interpolate data in the middle of standard text, use one of the templating modules, some of them work for text, not just html.

As Occam said: Entia non sunt multiplicanda praeter necessitatem.

  • Comment on Re: Formatting Strings Without Interpolating Whitespace

Replies are listed 'Best First'.
Re^2: Formatting Strings Without Interpolating Whitespace
by BJ_Covert_Action (Beadle) on Jan 20, 2012 at 04:03 UTC

    That would involve expanding this particular script's capabilities far beyond what is needed right now. Down the line I do intend to do exactly as you say (one problem of course, is that if I use external template files then I have to version control the template files if they start getting updated). However, I needed to get something out the door today, and digging through/researching templating modules while simultaneously trying to get my formats right, my parsing right, and my e-mail configuration right was going to require a lot of time that I don't have right now.

    One day, if all goes well, I fully intend to evolve this into a completely modular, badass notification program. But for the time being, that amount of work would not be adding value to my immediate task at hand

    So, long story short, I'm prioritizing.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://948875]
[hippo]: That's equal parts clever and horrendous.
[Eily]: the overload version wouldn't return true with "$x" && !length $x though, I guess
[hippo]: The more I look at this code, the more $x is a plain old scalar and the more this condition will never be true. I'm calling it a bug at this point.
[hippo]: Thanks for your input which has soothed my sanity (a little)
[Corion]: Eily: Sure - if you force both things into stringy things, then you break that magic. But that would also mean that you changed the expression, as now $x = 0.00 will be true instead of false as it were before
[Corion]: Ah no, at least in my feeble experiments that doesn't change the meaning
[Corion]: We sell sanity in small packages ;)

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (8)
As of 2017-07-27 13:42 GMT
Find Nodes?
    Voting Booth?
    I came, I saw, I ...

    Results (414 votes). Check out past polls.