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

urgent help needed

Expand Messages
  • Minjal Pandejee - ASIC
    Hi, I am a beginner in perl and I have a query regarding pattern matching. I came across a line in perl where it was written $variable =~ s-/ Z--; and as the
    Message 1 of 3 , Jul 1, 2011
    • 0 Attachment
      Hi,

      I am a beginner in perl and I have a query regarding pattern matching.
      I came across a line in perl where it was written
      $variable =~ s-/\Z--;

      and as the code goes ahead some another variable was assigned
      $variable1 =~ s-/--;

      can you please tell me what does these 2 lines do?
      I want to know what does s-/\Z-- and s-/-- mean.

      Thanks & Regards
      Minjal Pandejee
    • Alan Haggai Alavi
      Hello Minjal, This was answered here: http://stackoverflow.com/questions/6556904/what-does-s-and-s-z-in-perl-mean By the way, it is a bad idea to use the word
      Message 2 of 3 , Jul 2, 2011
      • 0 Attachment
        Hello Minjal,

        This was answered here:
        http://stackoverflow.com/questions/6556904/what-does-s-and-s-z-in-perl-mean

        By the way, it is a bad idea to use the word 'urgent' for requests. Not many
        people look into such requests.

        Regards,
        Alan Haggai Alavi.
        --
        The difference makes the difference.
      • Shawn H Corey
        ... The first character that follow an s is the delimiter. So the above is equivalent to: $variable =~ s/ / Z//; The meta-character Z will match an optional
        Message 3 of 3 , Jul 3, 2011
        • 0 Attachment
          On 11-07-02 12:48 AM, Minjal Pandejee - ASIC wrote:
          > Hi,
          >
          > I am a beginner in perl and I have a query regarding pattern matching.
          > I came across a line in perl where it was written
          > $variable =~ s-/\Z--;

          The first character that follow an s is the delimiter. So the above is
          equivalent to:

          $variable =~ s/\/\Z//;

          The meta-character \Z will match an optional newline and the end of the
          string. It is the same as:

          $variable =~ s/\/\n?$//;

          >
          > and as the code goes ahead some another variable was assigned
          > $variable1 =~ s-/--;

          It's equivalent would be:

          $variable1 =~ s/\///;

          >
          > can you please tell me what does these 2 lines do?
          > I want to know what does s-/\Z-- and s-/-- mean.
          >
          > Thanks& Regards
          > Minjal Pandejee
          >

          See:
          perldoc perlretut
          perldoc perlre


          --
          Just my 0.00000002 million dollars worth,
          Shawn

          Confusion is the first step of understanding.

          Programming is as much about organization and communication
          as it is about coding.

          The secret to great software: Fail early & often.

          Eliminate software piracy: use only FLOSS.
        Your message has been successfully submitted and would be delivered to recipients shortly.