SPUG: Anyone savvy in this?

Tom Heady perl-win32 at punch.net
Wed Jan 30 19:45:18 CST 2002


another safer option
my $replace = "<br />";
$row[4] =~ s/\Q$replace\E/<br>/g;


*********** REPLY SEPARATOR  ***********

On 1/30/2002 at 11:04 AM Ben Reser wrote:

>On Wed, Jan 30, 2002 at 10:31:09AM -0800, Chris Wilkes wrote:
>> Now I have a question about this, what if she said
>> 	$br = "< br />";
>> 	$row[4] =~ s/$br/somethinghere/g;
>> Why doesn't that blow up?  Good thing I checked this, I thought it did
>> gives problems in previous versions of perl and was going to ask how to
>> get around it. 
>
>Because the parser knows what you mean.  You can't do:
>$x = "print 'this';"
>$x;
>
>So why would it expand before executing the pattern?
>
>Frankly if you want to do something with /'s in it you should be doing
>something like this:
>s#<br />#\n#g;
>or whatever other delimeter you want that is compatable with your
>pattern.
>:)
>
>-- 
>Ben Reser <ben at reser.org>
>http://ben.reser.org
>
>What difference does it make to the dead, the orphans, and the homeless,
>whether the mad destruction is wrought under the name of totalitarianism
>or the holy name of liberty and democracy? - Ghandi
>
> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
>     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
>      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
>  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
> For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
>     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org




 - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
     POST TO: spug-list at pm.org       PROBLEMS: owner-spug-list at pm.org
      Subscriptions; Email to majordomo at pm.org:  ACTION  LIST  EMAIL
  Replace ACTION by subscribe or unsubscribe, EMAIL by your Email-address
 For daily traffic, use spug-list for LIST ;  for weekly, spug-list-digest
     Seattle Perl Users Group (SPUG) Home Page: http://seattleperl.org





More information about the spug-list mailing list