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

Multiple values per key (Hash)

Expand Messages
  • Charith Dias
    Hello,   Good afternoon. I want to open a file and store data in a HASH. Well, my input file format is like this (a Csv file with list of
    Message 1 of 4 , Jul 1, 2008
    • 0 Attachment
      Hello,
       
      Good afternoon.
      I want to open a file and store data in a HASH. Well, my input file format is like this (a Csv file with list of CityNumbers,X_Coordinate, Y_Coordinate).
      2,0,40
      3,5,42
      4,6,26
      . . .
       
      Can somebody kindly tell me how can I store data. I mean how can I assign 2 values(Multiple values) per one key in a Hash.
       
      Thanks in advance,
       
      Regards,
       
      Charitha DIAS
       




      [Non-text portions of this message have been removed]
    • Amit Saxena
      You have to use references for the same. For a key, you can assign the value as array or hash reference. Since references are scaler values only, Perl will not
      Message 2 of 4 , Jul 1, 2008
      • 0 Attachment
        You have to use references for the same.

        For a key, you can assign the value as array or hash reference. Since
        references are scaler values only, Perl will not
        complain and you also can get multiple values per key in that hash.

        Regards,
        Amit Saxena

        On Wed, Jul 2, 2008 at 10:31 AM, Charith Dias <charith_dias@...>
        wrote:

        > Hello,
        >
        > Good afternoon.
        > I want to open a file and store data in a HASH. Well, my input file format
        > is like this (a Csv file with list of CityNumbers,X_Coordinate,
        > Y_Coordinate).
        > 2,0,40
        > 3,5,42
        > 4,6,26
        > . . .
        >
        > Can somebody kindly tell me how can I store data. I mean how can I assign 2
        > values(Multiple values) per one key in a Hash.
        >
        > Thanks in advance,
        >
        > Regards,
        >
        > Charitha DIAS
        >
        >
        > [Non-text portions of this message have been removed]
        >
        >
        >


        [Non-text portions of this message have been removed]
      • vidhut singh
        Here is the example which shows multiple values can be stored in one hash . e.g $hash{$key}- {$x_corrd}= $val $hash{$key}- {$y_corrd}=$val -Regards, vidhut ...
        Message 3 of 4 , Jul 1, 2008
        • 0 Attachment
          Here is the example which shows multiple values can be stored in one hash .
          e.g
          $hash{$key}->{$x_corrd}= $val
          $hash{$key}->{$y_corrd}=$val
          -Regards,
          vidhut


          --- On Wed, 2/7/08, Amit Saxena <learn.tech123@...> wrote:
          From: Amit Saxena <learn.tech123@...>
          Subject: Re: [PBML] Multiple values per key (Hash)
          To: perl-beginner@yahoogroups.com
          Date: Wednesday, 2 July, 2008, 10:39 AM











          You have to use references for the same.



          For a key, you can assign the value as array or hash reference. Since

          references are scaler values only, Perl will not

          complain and you also can get multiple values per key in that hash.



          Regards,

          Amit Saxena



          On Wed, Jul 2, 2008 at 10:31 AM, Charith Dias <charith_dias@ yahoo.com>

          wrote:



          > Hello,

          >

          > Good afternoon.

          > I want to open a file and store data in a HASH. Well, my input file format

          > is like this (a Csv file with list of CityNumbers, X_Coordinate,

          > Y_Coordinate) .

          > 2,0,40

          > 3,5,42

          > 4,6,26

          > . . .

          >

          > Can somebody kindly tell me how can I store data. I mean how can I assign 2

          > values(Multiple values) per one key in a Hash.

          >

          > Thanks in advance,

          >

          > Regards,

          >

          > Charitha DIAS

          >

          >

          > [Non-text portions of this message have been removed]

          >

          >

          >



          [Non-text portions of this message have been removed]



























          Forgot the famous last words? Access your message archive online at http://in.messenger.yahoo.com/webmessengerpromo.php

          [Non-text portions of this message have been removed]
        • Charith Dias
          Hello,   Thanks a lot!! I got the required output. :)   Regards,   Charitha DIAS     ... From: vidhut singh Subject: Re: [PBML]
          Message 4 of 4 , Jul 3, 2008
          • 0 Attachment
            Hello,
             
            Thanks a lot!! I got the required output. :)
             
            Regards,
             
            Charitha DIAS
             
             


            --- On Tue, 7/1/08, vidhut singh <chat2vidhut@...> wrote:

            From: vidhut singh <chat2vidhut@...>
            Subject: Re: [PBML] Multiple values per key (Hash)
            To: perl-beginner@yahoogroups.com
            Date: Tuesday, July 1, 2008, 10:20 PM






            Here is the example which shows multiple values can be stored in one hash .
            e.g
            $hash{$key}- >{$x_corrd} = $val
            $hash{$key}- >{$y_corrd} =$val
            -Regards,
            vidhut

            --- On Wed, 2/7/08, Amit Saxena <learn.tech123@ gmail.com> wrote:
            From: Amit Saxena <learn.tech123@ gmail.com>
            Subject: Re: [PBML] Multiple values per key (Hash)
            To: perl-beginner@ yahoogroups. com
            Date: Wednesday, 2 July, 2008, 10:39 AM

            You have to use references for the same.

            For a key, you can assign the value as array or hash reference. Since

            references are scaler values only, Perl will not

            complain and you also can get multiple values per key in that hash.

            Regards,

            Amit Saxena

            On Wed, Jul 2, 2008 at 10:31 AM, Charith Dias <charith_dias@ yahoo.com>

            wrote:

            > Hello,

            >

            > Good afternoon.

            > I want to open a file and store data in a HASH. Well, my input file format

            > is like this (a Csv file with list of CityNumbers, X_Coordinate,

            > Y_Coordinate) .

            > 2,0,40

            > 3,5,42

            > 4,6,26

            > . . .

            >

            > Can somebody kindly tell me how can I store data. I mean how can I assign 2

            > values(Multiple values) per one key in a Hash.

            >

            > Thanks in advance,

            >

            > Regards,

            >

            > Charitha DIAS

            >

            >

            > [Non-text portions of this message have been removed]

            >

            >

            >

            [Non-text portions of this message have been removed]











            Forgot the famous last words? Access your message archive online at http://in.messenger .yahoo.com/ webmessengerprom o.php

            [Non-text portions of this message have been removed]


















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