I believed to be alone in the world of paranoid thoughts (1), but you seem to surpass me.
... I'm forced to initially assign it with a value that clearly isn't squished. In fact, 'don't like' isn't close, I really hate bad variables names.
I agree with you with the genaral idea (calling the variable $another_form_for_name would be bad), but not in the application in this particular case: you're adjusting the value on the very following line, so I don't think that your assignment breaks any understandability in the code. At last, using good variable names is all about readability and understandability, isn't it?

Probably you're happy with the previous answers, but probably you're just because your variable lives some instants in which it holds data that do not match the semantic you assign to the variable. If this is the case (skip the following if it's not, of course), the particular problem seems that you want to assign a static/fixed semantic to the variable, declared by its name. This seems near to a contradiction-in-terms, just because it's a variable, and variables should be meant to evolve during their life. You can stick with this:

my $name = "Rob J Anderson"; (my $tmp_for_squishing = $name) =~ s/\W//g; my $squished_name = $tmp_for_squishing;
just to be sure that $squished_name won't ever contain a non-squished value, but does it add value to the code or does it make the code harder to read?

The general answer I received to my paranoid post can be boiled down to this: as long as the program is readable, maintainable, correct and does its job in the correct time... don't waste time on these time-consuming issues!

(1)Testing at the right granularity and Writing general code: real world example - and doubts! for a few examples of my level of paranoid.

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

Don't fool yourself.

In reply to Re: Idiom for a regex translation by polettix
in thread Idiom for a regex translation by reasonablekeith

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, details, 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, summary, 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.