in reply to Re: Re: How do I use regex to strip out specific characters in a string?
in thread How do I use regex to strip out specific characters in a string?

I agree with the tr/// instead of the s///.

But, the creation of temp variables shouldn't be an issue. But, if you're that concerned with the creation of temporary variables, just undef the variables after you're done. You could even combine the variables as such:

{ my @temp_variables; push @temp_variables, split ' ', $stamp; push @temp_variables, split '/', $temp_variable[1]; $temp_variables[2] =~ tr/://d; $stamp = join '_', @temp_variables[3,4,2]; undef @temp_variables; }

------
/me wants to be the brightest bulb in the chandelier!

Vote paco for President!

  • Comment on Re: Re: Re: How do I use regex to strip out specific characters in a string?
  • Download Code

Replies are listed 'Best First'.
Re: Re: Re: Re: How do I use regex to strip out specific characters in a string?
by Sifmole (Chaplain) on Aug 23, 2001 at 00:58 UTC
    Temporary variables can clutter things up, and cause confusion. You solution seems to start leaning more towards the confusing side as well. I know that I personally would want to see a good regular expression rather than a bunch of array slice uses.

    Perhaps it is just personal preference.

      I suspect it is personal preference. However, any time someone is using a regex to parse out a line of text, I start itching to rewrite. That's just getting too fancy-schmancy for maintainable code ... in my opinion. (I don't want to start a crusade here!)

      ------
      /me wants to be the brightest bulb in the chandelier!

      Vote paco for President!

        What would you consider a good use of a regex?