Professional Web Applications Themes

How I do replace part of a string - PERL Beginners

Hi, I have the following as my test output file: A::ThrowOutALL 10657939000 A::ThrowOutEvents 15861 I want to run it thru some filtering so as to generate something like A::ThrowOutALL 10000000000 A::ThrowOutEvents 10000 So that I can compare it to a golden output. Thanks, Raman...

  1. #1

    Default How I do replace part of a string

    Hi,

    I have the following as my test output file:

    A::ThrowOutALL 10657939000
    A::ThrowOutEvents 15861

    I want to run it thru some filtering so as to generate something like

    A::ThrowOutALL 10000000000
    A::ThrowOutEvents 10000

    So that I can compare it to a golden output.

    Thanks,
    Raman
    Raman Guest

  2. #2

    Default Re: How I do replace part of a string

    On Wed, 08 Sep 2004 13:17:18 -0700, Raman Ravi wrote:
     

    perldoc -f split
    perldoc -f substr

    May help. What would help more would be if you posted some code which does
    something close to what you want and then we can post
    suggestions/improvements. This is currently too vague and doesn't show
    what you've tried (if anything).
     
    What's a golden output?

    Chris.
    Chris Guest

  3. #3

    Default Re: How I do replace part of a string

    Chris Cole <com> wrote in message news:<com>... 
    >
    > perldoc -f split
    > perldoc -f substr
    >
    > May help. What would help more would be if you posted some code which does
    > something close to what you want and then we can post
    > suggestions/improvements. This is currently too vague and doesn't show
    > what you've tried (if anything).

    > What's a golden output?
    >
    > Chris.[/ref]


    Hi Chris,

    Thanks for the reply.


    golden output is what I expect these unit tests to do.

    So far I have been brute-forcing it by

    a. grepping out the "Throwout" string and then comparing current
    output with the golden output - Not very accurate
    or
    b. I have been using "sed" with which I can manipulate fixed strings,
    like

    sed -e 's/A::ThrowOutALL 10[0-9]*$/A::ThrowOutALL 1000000000/g"

    While it works right now because the length of the number part is
    fixed, in the future it will change, so this solution is not practical
    either.

    I heard perl is much better at parsing/manipulating strings, hence
    forth this request, as I have never worked with perl.

    Thanks,
    Raman
    Raman Guest

Similar Threads

  1. replace() string
    By dweeres in forum Coldfusion - Getting Started
    Replies: 3
    Last Post: May 1st, 04:26 AM
  2. Replace String
    By Michael42 in forum Macromedia ColdFusion
    Replies: 1
    Last Post: February 22nd, 06:58 PM
  3. Help with string replace...
    By Tihon in forum PHP Development
    Replies: 7
    Last Post: February 6th, 12:52 PM
  4. P part of string (mid string function ?)
    By mimages in forum PHP Development
    Replies: 7
    Last Post: September 27th, 12:58 AM
  5. Replies: 4
    Last Post: September 12th, 04:19 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139