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

problem with a hash

Expand Messages
  • Stefan Hotz
    Hello I am including a file ( bu.pm) to my main file. In this main file I would like to change some values ( like $BU{heinz}{title} change from meier to
    Message 1 of 2 , May 28, 2002
      Hello

      I am including a file ( bu.pm) to my main file. In this main file I would
      like to change some values ( like $BU{heinz}{title} change from "meier" to
      "james" ) or add some additional keys. Can I save the changes without
      opening a filehandle and write it back. I have read maybe with the dump
      function it would be possible.

      How can I do this.

      Thank's for any help

      Stefan



      *********************************

      file main.pm

      require bu.pm

      $BU{heinz}{title} = james; # modify a value

      $BU{susi} # Add a new key with some values

      ***********************************

      file bu.pm

      %BU = (
      heinz => {
      title => "meier",
      CIR => 4520000,
      Burst => 6780000,
      oid => 1008,
      },
      peter => {
      title => "muller",
      CIR => 324000,
      Burst => 656000,
      oid => 3171,
      },

      ***********************************






      ******************* PLEASE NOTE *******************
      This message, along with any attachments, may be confidential or legally
      privileged. It is intended only for the named person(s), who is/are the
      only authorized recipients. If this message has reached you in error,
      kindly destroy it without review and notify the sender immediately. Thank
      you for your help.
    • jamesekeenan
      ... would ... from meier to ... without ... dump ... 1. A point of nomenclature: These days, the .pm file extension is generally used for Perl modules.
      Message 2 of 2 , Jun 3, 2002
        --- In perl-beginner@y..., "Stefan Hotz" <stefan.hotz@z...> wrote:
        >
        > I am including a file ( bu.pm) to my main file. In this main file I
        would
        > like to change some values ( like $BU{heinz}{title} change
        from "meier" to
        > "james" ) or add some additional keys. Can I save the changes
        without
        > opening a filehandle and write it back. I have read maybe with the
        dump
        > function it would be possible.
        >
        > How can I do this.
        >
        > *********************************
        >
        > file main.pm
        >
        > require bu.pm
        >
        > $BU{heinz}{title} = james; # modify a value
        >
        > $BU{susi} # Add a new key with some values
        >
        > ***********************************
        >
        > file bu.pm
        >
        > %BU = (
        > heinz => {
        > title => "meier",
        > CIR => 4520000,
        > Burst => 6780000,
        > oid => 1008,
        > },
        > peter => {
        > title => "muller",
        > CIR => 324000,
        > Burst => 656000,
        > oid => 3171,
        > },
        >
        > ***********************************
        1. A point of nomenclature: These days, the ".pm" file extension is
        generally used for Perl modules. It should not be used for Perl
        scripts or for libraries.

        2. Check out the Tie::Hash function on CPAN:
        http://search.cpan.org/doc/GSAR/perl-5.6.1-TRIAL3/lib/Tie/Hash.pm

        Jim Keenan
        jkeen@...
      Your message has been successfully submitted and would be delivered to recipients shortly.