comparing array value...

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default comparing array value...

    Hello there,

    could somebody let me know how do i compare the contents of an array that I
    have...
    To be specific.

    my array contains something like below and i need to compare whether the
    string "interface ATM2/0.10 multipoint"
    exists in my array.

    ---------------------------------------------------
    Building configuration...

    Current configuration : 130 bytes
    !
    interface ATM2/0.10 multipoint
    description config vp thru program for slot2
    range pvc 10/32 10/1023
    class-range dbs
    !
    end
    ----------------------------------------------------

    ----------------------------------------------------------------------------
    ----------------

    regards,

    Ajitpal Singh,
    Ajit P Singh Guest

  2. Similar Questions and Discussions

    1. Comparing Time
      I am trying to query a DB for all records that were created by one user, on one day and between two time periods. Here is my codet: <cfset...
    2. Comparing values
      i have created three fields named (username, surname & pin) and when the user enters in the information, i want it to compare the values from three...
    3. Comparing 2 hashes of array refs
      On 11 Jul 2003, simo wrote: It's best to cut and paste from your code, as opposed to retyping. Hashes are defined by parenthesis, not by...
    4. Comparing two tables
      Hi, I would have to make code in C++ that would check two database tables for differencies. The two tables should be identical. If there are any...
    5. comparing rows in a multidimensional array
      how can i compare rows (3 or more rows) in a multidiemensional array? they all contain numeric values, i need to find its similar values and unique...
  3. #2

    Default Re: comparing array value...

    On Feb 3, 2004, at 7:59 AM, Singh, Ajit p wrote:
    > Hello there,
    >
    > could somebody let me know how do i compare the contents of an array
    > that I
    > have...
    > To be specific.
    >
    > my array contains something like below and i need to compare whether
    > the
    > string "interface ATM2/0.10 multipoint"
    > exists in my array.
    >
    > ---------------------------------------------------
    > Building configuration...
    >
    > Current configuration : 130 bytes
    > !
    > interface ATM2/0.10 multipoint
    > description config vp thru program for slot2
    > range pvc 10/32 10/1023
    > class-range dbs
    > !
    > end
    > ----------------------------------------------------
    How about something like this:

    if (contains("interface ATM2/0.10 multipoint", @config)) {
    # do something...
    }

    sub contains {
    my($string, @line) = @_;
    foreach (@lines) { return 1 if /\Q$string/; } # return true if we
    fine the string
    return; # false if we don't
    }

    Hope that helps.

    James

    James Edward Gray II Guest

  4. #3

    Default RE: comparing array value...

    Singh, Ajit p <ajit.pal.singh@thus.net> wrote:
    :
    : Hello there,
    :
    : Could somebody let me know how do I compare the
    : contents of an array that I have. To be specific,
    : my array contains something like below and I need
    : to compare whether the string
    : "interface ATM2/0.10 multipoint" exists in my
    : array.

    Why is this data in an array? If you are going
    to search it, it would be nicer if it were in a
    scalar or in a hash. How did it get in an array to
    begin with?


    HTH,

    Charles K. Clarkson
    --
    Head Bottle Washer,
    Clarkson Energy Homes, Inc.
    Mobile Home Specialists
    254 968-8328

    Charles K. Clarkson Guest

  5. #4

    Default Re: comparing array value...

    "Singh, Ajit p" wrote:
    > Hello there,
    >
    > could somebody let me know how do i compare the contents of an array that I
    > have...
    > To be specific.
    >
    > my array contains something like below
    Why? I see nothing uniform between the lines of the array tosuggest that they
    should be handled as array elements. What you show below looks like text,
    possibly a block. Is the whole block an array element? That might be a
    sensible arrangement, if you have a series of blocks of similar format. If not,
    then you probably need to rethink how you are loading your array.

    Array operations on heterogenous data like that shown below will be exceedinbly
    clumsy. If you start by defining your problem, what data you have available,
    and what information you want to generate from it, we can probably help you find
    more appropriate ways to process it.
    > ...
    > Building configuration...
    >
    > Current configuration : 130 bytes
    > !
    > interface ATM2/0.10 multipoint
    > description config vp thru program for slot2
    > range pvc 10/32 10/1023
    > class-range dbs
    > !
    > end
    Joseph

    R. Joseph Newton Guest

Posting Permissions

  • You may not post new threads
  • You may 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