Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Switch

Expand Messages
  • J.E. Cripps
    ... Switch? No switch in perl right now :-) That s not what you want anyway. I think what you want is the substitution operator. $ perldoc perlop
    Message 1 of 3 , May 9, 2005
    • 0 Attachment
      > Anyone know the switch code for searching for a (.) and replacing it
      > with the word (dot) and vice versa?

      Switch? No "switch" in perl right now :-)

      That's not what you want anyway.

      I think what you want is the substitution operator.
      $ perldoc perlop
    • Damien Carbery
      ... The . is a special character in regular expressions - it matches *any* character. To make it match a . you have to escape it i.e. prefix it with a
      Message 2 of 3 , May 9, 2005
      • 0 Attachment
        --- In perl-beginner@yahoogroups.com, "tech20052003"
        <tech20052003@y...> wrote:
        >
        > Anyone know the switch code for searching for a (.) and replacing it
        > with the word (dot) and vice versa?

        The '.' is a special character in regular expressions - it matches
        *any* character. To make it match a '.' you have to 'escape' it i.e.
        prefix it with a slash '\'.

        To substitute ('switch' as you call it) '.' with 'dot' you will use
        the substitute operator with something like:

        $data =~ s/\./dot/g;

        The 'g' modifier tells it to substitute all '.' chars, otherwise it
        would stop after the first one.

        As JE Cripps said, there is more information in the 'perlop' section
        of the docs.
      Your message has been successfully submitted and would be delivered to recipients shortly.