Re: Switching two characters

2008-09-23 Thread Paolo Gianrossi
On Mon, 2008-09-22 at 20:16 -0700, Grant wrote: > what about > > $code =~ tr/['"]/["']/; > > ? > >>> > >>> I shouldn't have said characters. I'm actually trying to switch "'" > >>> and "'" without the double-quotes. Can that be done as simply as > >>> your one-liner above

Re: Switching two characters

2008-09-23 Thread Paolo Gianrossi
On Mon, 2008-09-22 at 11:08 -0700, John W. Krahn wrote: > Paolo Gianrossi wrote: > > what about > > > > $code =~ tr/['"]/["']/; > > Why are you also replacing '[' with '[' and ']' with ']'? > > Perhaps you meant: > > $code =~ tr['"]["']; > > Wooops you're right... Sorry for the slightly wron

Re: Switching two characters

2008-09-22 Thread Grant
what about $code =~ tr/['"]/["']/; ? >>> >>> I shouldn't have said characters. I'm actually trying to switch "'" >>> and "'" without the double-quotes. Can that be done as simply as >>> your one-liner above? >> >> perldoc HTML::Entities >> >> Or: http://search.cpan.org/~g

Re: Switching two characters

2008-09-22 Thread Grant
>>> what about >>> >>> $code =~ tr/['"]/["']/; >>> >>> ? >> >> I shouldn't have said characters. I'm actually trying to switch "'" >> and "'" without the double-quotes. Can that be done as simply as >> your one-liner above? > > perldoc HTML::Entities > > Or: http://search.cpan.org/~gaas/HTML-Pars

Re: Switching two characters

2008-09-22 Thread John W. Krahn
Grant wrote: what about $code =~ tr/['"]/["']/; ? I shouldn't have said characters. I'm actually trying to switch "'" and "'" without the double-quotes. Can that be done as simply as your one-liner above? perldoc HTML::Entities Or: http://search.cpan.org/~gaas/HTML-Parser-3.56/lib/HTML/E

Re: Switching two characters

2008-09-22 Thread Grant
>> > what about >> > >> > $code =~ tr/['"]/["']/; >> > >> > ? >> >> I shouldn't have said characters. I'm actually trying to switch "'" >> and "'" without the double-quotes. Can that be done as simply as >> your one-liner above? > > $code = s{ (['\x22]) }{ '&#' . ord( $1 ) . ';' }egx; Thanks but

Re: Switching two characters

2008-09-22 Thread Mr. Shawn H. Corey
On Mon, 2008-09-22 at 10:34 -0700, Grant wrote: > > what about > > > > $code =~ tr/['"]/["']/; > > > > ? > > I shouldn't have said characters. I'm actually trying to switch "'" > and "'" without the double-quotes. Can that be done as simply as > your one-liner above? $code = s{ (['\x22]) }{ '&#

Re: Switching two characters

2008-09-22 Thread John W. Krahn
Paolo Gianrossi wrote: what about $code =~ tr/['"]/["']/; Why are you also replacing '[' with '[' and ']' with ']'? Perhaps you meant: $code =~ tr['"]["']; John -- Perl isn't a toolbox, but a small machine shop where you can special-order certain sorts of tools at low cost and in short o

Re: Switching two characters

2008-09-22 Thread John W. Krahn
Grant wrote: I'd like to switch the " and ' characters in a block of text so that all " characters become ' and all ' characters become ". The closest thing I can come up with is the following, but of course it doesn't work quite right because one is executed after the other: $code =~ s/"/'/g;

Re: Switching two characters

2008-09-22 Thread Grant
> what about > > $code =~ tr/['"]/["']/; > > ? I shouldn't have said characters. I'm actually trying to switch "'" and "'" without the double-quotes. Can that be done as simply as your one-liner above? - Grant >> I'd like to switch the " and ' characters in a block of text so that >> all " cha

Re: Switching two characters

2008-09-22 Thread Mr. Shawn H. Corey
On Mon, 2008-09-22 at 10:19 -0700, Grant wrote: > I'd like to switch the " and ' characters in a block of text so that > all " characters become ' and all ' characters become ". The closest > thing I can come up with is the following, but of course it doesn't > work quite right because one is exec

Re: Switching two characters

2008-09-22 Thread Paolo Gianrossi
what about $code =~ tr/['"]/["']/; ? Hope it helps :) cheers paolino On Mon, 2008-09-22 at 10:19 -0700, Grant wrote: > I'd like to switch the " and ' characters in a block of text so that > all " characters become ' and all ' characters become ". The closest > thing I can come up with is th

Switching two characters

2008-09-22 Thread Grant
I'd like to switch the " and ' characters in a block of text so that all " characters become ' and all ' characters become ". The closest thing I can come up with is the following, but of course it doesn't work quite right because one is executed after the other: $code =~ s/"/'/g; $code =~ s/'/"/