Nestor Florez wrote:
> 
> From: "John W. Krahn" <[EMAIL PROTECTED]>
> 
> > Birgit Kellner wrote:
> > >
> > > while ($string =~ /(<[^>]*?)"/gs) {
> > >         my $var = $1;
> > >         $string =~ s/$var"/$var'/;}
> > >
> > > print qq|$string\n|;
> >
> > $string =~ s/(<[^>]+>)/$a=$1;$a=~tr|"|'|;$a/eg;
> 
> can you explain the piece of code that you wrote.


Here is the verbose version.

$string =~ s{            # start regular expression
              (          # start capture
                <        # match a less-than symbol
                [^>]+    # match one or more characters not a greater-than symbol
                >        # match a greater-than symbol
              )          # end capture
            }
            {            # start replacement expression
              $a = $1;   # can't modify $1 so copy it
              $a =~ tr|"|'|;  # replace double quotes with single quotes
              $a         # use this new string to replace the old one
            }gex;        # g = global pattern match
                         # e = evaluate the replacement expression
                         # x = allow whitespace and comments



John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to