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

Please help to correct the perl program?

Expand Messages
  • sajan_c_r
    sir, i need to find one string from paragraph and to convert all the letters in paragraph to X , except that string. can anyone help to correct it. i have
    Message 1 of 5 , Feb 24, 2009
    • 0 Attachment
      sir, i need to find one string from paragraph and to convert all the
      letters in paragraph to 'X', except that string. can anyone help to
      correct it. i have used string matching and wrote a program. i have
      used

      $para=~ s/$string/X/g

      then the string itself changing to X. pls help anynone.

      thanks in advance.
    • merlyn@stonehenge.com
      ... sajan sir, i need to find one string from paragraph and to convert all the sajan letters in paragraph to X , except that string. can anyone help to
      Message 2 of 5 , Feb 25, 2009
      • 0 Attachment
        >>>>> "sajan" == sajan c r <sajan_c_r@...> writes:

        sajan> sir, i need to find one string from paragraph and to convert all the
        sajan> letters in paragraph to 'X', except that string. can anyone help to
        sajan> correct it. i have used string matching and wrote a program. i have
        sajan> used

        Sounds like a great homework problem. Why don't you ask your instructor,
        rather than asking us to help you cheat?

        --
        Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
        <merlyn@...> <URL:http://www.stonehenge.com/merlyn/>
        Smalltalk/Perl/Unix consulting, Technical writing, Comedy, etc. etc.
        See http://methodsandmessages.vox.com/ for Smalltalk and Seaside discussion
      • mrkcoconnell
        Hi Sajan, I am working on this problem and I found all that I could get out of $para was the number of substitutions. The way this seems to work is on the
        Message 3 of 5 , Feb 25, 2009
        • 0 Attachment
          Hi Sajan,
          I am working on this problem and I found all that I could get out of
          $para was the number of substitutions.
          The way this seems to work is on the variable $_ which is the generic
          variable.
          When I printed out the $_ I found that my substitution was successful.
          I'll keep working and let you know what I find.
          Kevin
          --- In perl-beginner@yahoogroups.com, "sajan_c_r" <sajan_c_r@...>
          wrote:
          >
          > sir, i need to find one string from paragraph and to convert all the
          > letters in paragraph to 'X', except that string. can anyone help to
          > correct it. i have used string matching and wrote a program. i have
          > used
          >
          > $para=~ s/$string/X/g
          >
          > then the string itself changing to X. pls help anynone.
          >
          > thanks in advance.
          >
        • David Francos (XayOn)
          ... Ok. So I assume you want $para=~s/[^$string]/X/g; ... just a ^ to look for non-matching things. ... -- -- http://thexayon.wordpress.com Que la fuerza os
          Message 4 of 5 , Feb 25, 2009
          • 0 Attachment
            On Wed, Feb 25, 2009 at 04:54:40PM -0000, mrkcoconnell wrote:
            > Hi Sajan,
            > I am working on this problem and I found all that I could get out of
            > $para was the number of substitutions.
            > The way this seems to work is on the variable $_ which is the generic
            > variable.
            > When I printed out the $_ I found that my substitution was successful.
            > I'll keep working and let you know what I find.
            > Kevin
            > --- In perl-beginner@yahoogroups.com, "sajan_c_r" <sajan_c_r@...>
            > wrote:
            > >
            > > sir, i need to find one string from paragraph and to convert all the
            > > letters in paragraph to 'X', except that string. can anyone help to
            > > correct it. i have used string matching and wrote a program. i have
            > > used
            > >
            > > $para=~ s/$string/X/g
            Ok. So I assume you want $para=~s/[^$string]/X/g; ... just a ^ to look
            for non-matching things.
            > > then the string itself changing to X. pls help anynone.
            > > thanks in advance.

            >
            >

            --
            --
            http://thexayon.wordpress.com

            Que la fuerza os acompaƱe.

            -----BEGIN GEEK CODE BLOCK-----
            Version: 3.12
            GCS dpu s: a--- C++++ UL++++ P++++ L+++ E--- W+++ N+++ o+ K- w---
            O M+ V- PS+ PE+++ Y PGP++ t--- 5 X+++ R tv+++ b++++ DI--- D+++
            G+ e- h++ r+++ y++++
            ------END GEEK CODE BLOCK------

            --XayOn--

            Linux registered user #446872




            [Non-text portions of this message have been removed]
          • Jeff Pinyan
            ... That s because you re doing: $para = s/something/X/g; instead of $para =~ s/something/X/g; You re using the = operator instead of the =~ operator. -- The
            Message 5 of 5 , Feb 25, 2009
            • 0 Attachment
              On Wed, Feb 25, 2009 at 11:54 AM, mrkcoconnell <mrkcoconnell@...>wrote:

              > I am working on this problem and I found all that I could get out of
              > $para was the number of substitutions.
              > The way this seems to work is on the variable $_ which is the generic
              > variable.
              > When I printed out the $_ I found that my substitution was successful.
              > I'll keep working and let you know what I find.
              >

              That's because you're doing:

              $para = s/something/X/g;

              instead of

              $para =~ s/something/X/g;

              You're using the = operator instead of the =~ operator.

              --
              The Cross Reference - http://thecrossreference.blogspot.com/
              Critical Mass (The Science of the Liturgy) -
              http://romanliturgy.blogspot.com/

              [Mary said,] "Do whatever he tells you." ~ John 2:5


              [Non-text portions of this message have been removed]
            Your message has been successfully submitted and would be delivered to recipients shortly.