~ substitute ' with `

Discussion in 'Perl Misc' started by BJ, Oct 2, 2009.

  1. BJ

    BJ Guest

    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
    BJ, Oct 2, 2009
    #1
    1. Advertising

  2. BJ

    Uri Guttman Guest

    >>>>> "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 ---------
    Uri Guttman, Oct 2, 2009
    #2
    1. Advertising

  3. BJ

    BJ Guest

    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/"
    BJ, Oct 2, 2009
    #3
  4. BJ

    BJ Guest

    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 ---------
    BJ, Oct 2, 2009
    #4
  5. BJ

    Uri Guttman Guest

    >>>>> "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 ---------
    Uri Guttman, Oct 2, 2009
    #5
  6. 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
    Eric Pozharski, Oct 3, 2009
    #6
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Matalote
    Replies:
    2
    Views:
    447
    Matalote
    Jan 26, 2004
  2. Replies:
    1
    Views:
    550
    J├╝rgen Exner
    Mar 7, 2004
  3. DC Gringo

    substitute for nested select query

    DC Gringo, May 3, 2005, in forum: ASP .Net
    Replies:
    6
    Views:
    4,721
    John Spiegel
    May 3, 2005
  4. Steve Richter
    Replies:
    5
    Views:
    723
    Steve Richter
    May 6, 2005
  5. Edwin Knoppert

    define byte asm substitute?

    Edwin Knoppert, Jan 11, 2006, in forum: ASP .Net
    Replies:
    0
    Views:
    489
    Edwin Knoppert
    Jan 11, 2006
Loading...

Share This Page