Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > ~ substitute ' with `

Reply
Thread Tools

~ substitute ' with `

 
 
BJ
Guest
Posts: n/a
 
      10-02-2009
We are trying to get a text area from screen and edit it to
replace ' with ` (to preent mysql record mark conflict) $title is could be
blank initially

$title = ~s/'/`/g ;
or even
$title =~s\/'/\`/g ;

Results "4294967295" for the value of $title !

Can anyone suggest a work arround.

Thanks for any comments.

Regards
BJ



 
Reply With Quote
 
 
 
 
Uri Guttman
Guest
Posts: n/a
 
      10-02-2009
>>>>> "B" == BJ <> writes:

B> We are trying to get a text area from screen and edit it to
B> replace ' with ` (to preent mysql record mark conflict) $title is could be
B> blank initially

B> $title = ~s/'/`/g ;

that is very wrong as the op is =~ with no space. you assigned $title
the negation of the s/// op result which was likely 0 and it inverted it
to all 1's which is the number you got.
B> or even
B> $title =~s\/'/\`/g ;

here you have the op correct but the s\/ is insane. i am not even sure
if that parses.

B> Can anyone suggest a work arround.

fix your op and learn to not put spaces inside perl's ops.

uri

--
Uri Guttman ------ -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
 
 
 
BJ
Guest
Posts: n/a
 
      10-02-2009
Sorry, no good the same result.
Problem was extras space in between between "= ~" should be "=~"
Thanks
..
"Tad J McClellan" <> wrote in message
news:...
> BJ <> wrote:
>
>> We are trying to get a text area from screen and edit it to
>> replace ' with `

>
>
> $title =~ tr/'/`/;
>
>
> --
> Tad McClellan
> email: perl -le "print scalar reverse qq/moc.noitatibaher\100cmdat/"



 
Reply With Quote
 
BJ
Guest
Posts: n/a
 
      10-02-2009
Thanks for the clue.

Problem was extras space in between between "= ~" should be "=~"

Works fine Now.

"Uri Guttman" <> wrote in message
news:...
>>>>>> "B" == BJ <> writes:

>
> B> We are trying to get a text area from screen and edit it to
> B> replace ' with ` (to preent mysql record mark conflict) $title is
> could be
> B> blank initially
>
> B> $title = ~s/'/`/g ;
>
> that is very wrong as the op is =~ with no space. you assigned $title
> the negation of the s/// op result which was likely 0 and it inverted it
> to all 1's which is the number you got.
> B> or even
> B> $title =~s\/'/\`/g ;
>
> here you have the op correct but the s\/ is insane. i am not even sure
> if that parses.
>
> B> Can anyone suggest a work arround.
>
> fix your op and learn to not put spaces inside perl's ops.
>
> uri
>
> --
> Uri Guttman ------ --------
> http://www.sysarch.com --
> ----- Perl Code Review , Architecture, Development, Training,
> Support ------
> --------- Gourmet Hot Cocoa Mix ----
> http://bestfriendscocoa.com ---------



 
Reply With Quote
 
Uri Guttman
Guest
Posts: n/a
 
      10-02-2009
>>>>> "B" == BJ <> writes:

B> Sorry, no good the same result.

learn to bottom post which is the proper style here. you acknowledged one clue
from me so do it again.

>> $title =~ tr/'/`/;


that is actually a better and faster solution to your original
problem. and it does work. tr/// is meant for character processing vs s///
which is for strings and regexes. your problem was replacing ' with `
which is exactly what tr/// is for.

uri

--
Uri Guttman ------ -------- http://www.sysarch.com --
----- Perl Code Review , Architecture, Development, Training, Support ------
--------- Gourmet Hot Cocoa Mix ---- http://bestfriendscocoa.com ---------
 
Reply With Quote
 
Eric Pozharski
Guest
Posts: n/a
 
      10-03-2009
On 2009-10-02, Uri Guttman <> wrote:
>>>>>> "B" == BJ <> writes:

*SKIP*
> B> $title =~s\/'/\`/g ;
>
> here you have the op correct but the s\/ is insane. i am not even sure
> if that parses.


It doesn't

Substitution replacement not terminated at -e line 1.

*CUT*

--
Torvalds' goal for Linux is very simple: World Domination
Stallman's goal for GNU is even simpler: Freedom
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
any MCDST exams can substitute 070-270 exam in MCSE? Daud Christian MCSE 30 05-30-2005 06:37 PM
Techie Re: any MCDST exams can substitute 070-270 exam in MCSE? Seelan MCSE 0 05-27-2005 03:25 PM
substitute for nested select query DC Gringo ASP .Net 6 05-03-2005 08:59 PM
Substitute UC with space UC flamencoman@earthlink.net Perl 1 03-07-2004 08:02 PM
3rd party reporting tools to substitute Crystal Matalote ASP .Net 2 01-26-2004 04:46 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57