Loading ...
Sorry, an error occurred while loading the content.

300Re: [NTS] Re: [Clip] Use RegExp to change case?

Expand Messages
  • acumming@cwnet.com
    May 11, 2005
      On Wed, 11 May 2005 10:40 , Sheri <silvermoonwoman@...> sent:

      >At 06:07 PM 5/7/2005 -0700, you wrote:
      >>Hi Daniel,
      >>I'm certainly no guru. But am recently leave the basics behind for intermediate
      and advanced Perl programming things such as: packages, namespaces, references,
      complex data structures, and perhaps now not too far away on the horizon: Perl
      Object Oriented programming.
      >LOL! I've forgotten everything I'm so out of practice I've forgotten everything I

      Hi! Well it's good to hear your voice on the list once again!

      I'm a couple years behind schedule. But I must be facsinated (sp) with the
      capabilities of Perl: enough familiarity with it then often equates to like "abbra
      cadabbra" sorts of things/capabilities.

      (See next too). But probably what it was doing with the for loop in it is that it
      was just doing one loop then finishing, ie processes all replacements in the first
      loop resulting in it's completed which in turn results in exiting the for loop so
      that therefore the for loop was/is not even needed. Ok, the gurus didn't have time
      to look or else perhaps they would have pointed that out to me.

      The good news is that I'm beginning to catch my own.

      (I'll try to remember to test this when I get on my other machine) A guru would
      know -- but likely could do without the for loop and I think it is so because of
      the g (global option) coupled with the regex operator already does goes through the
      entire string, doing all replacements. For example, to remove the for loop from
      the script:

      for ($text =~ s/(<strong>)(.*?)(<\/strong>)/$1\U$2\E$3/gis) {
      print $text;
      } # end

      So, those 3 lines would then instead become (and more correctly I think too) 2
      lines, thus:

      $text =~ s/(<strong>)(.*?)(<\/strong>)/$1\U$2\E$3/gis);
      print $text; # end

      (The unmodified original is enclosed next):

      ^!RunPerl pl_case_changer

      #!perl -w
      undef $/; # Enter "file slurp" mode.
      $text = <>; # This file/buffer/selection slurped into the scalar
      for ($text =~ s/(<strong>)(.*?)(<\/strong>)/$1\U$2\E$3/gis) {
      print $text;
      } # end


      ---- Msg sent via CWNet - http://www.cwnet.com/
    • Show all 5 messages in this topic