Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

PERL; input string has a $ sign...what to do?

  • 06-03-2007 8:45pm
    #1
    Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭


    I'm trying to extract the number '2' in the line "Blinds are now $1/$2" using regular expressions in perl. I'm running into problems because of the $ sign, it being the symbol used to denote variables in perl.

    Anyone know how I can get around this problem?

    edit: think I've got it. Stick extra quotes around it.


Comments

  • Registered Users, Registered Users 2 Posts: 6,571 ✭✭✭daymobrew


    You can always backslash the $ symbol to tell the regex engine that you mean it literally.
    if ( /Blinds are now \$1/\$(\d)/ ) {
      $TheNumberTwo = $1;  # == 2.
    }
    


  • Registered Users, Registered Users 2 Posts: 2,364 ✭✭✭Mr. Flibble


    The string is not generated by me, its passed externally - so I can't add the slashes without it knowing where the $s are.


Advertisement