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

Re: [blug-prog] PERL handling array of hash variables?

Expand Messages
  • Philip S Tellis
    ... [snip] Oh my God! Have you *ever* read man perl? References are best left to someone who s read the docs. -- Murphy s Law, that brash proletarian
    Message 1 of 7 , Nov 6 8:05 AM
      Sometime Today, Vivek Dosi assembled some asciibets to say:

      > #!/usr/bin/perl
      >
      > @arrayOfRec;
      >   $rec = {
      [snip]

      Oh my God! Have you *ever* read man perl? References are best left to
      someone who's read the docs.


      --
      Murphy's Law, that brash proletarian restatement of Godel's Theorem.
      -- Thomas Pynchon, "Gravity's Rainbow"
    • Kenneth Gonsalves
      ... also use strict kg
      Message 2 of 7 , Nov 6 8:12 PM
        On Thursday 06 November 2003 17:07, you wrote:
        > >>>>> "Vivek" == Vivek Dosi <vivek.dosi@...> writes:
        > >
        > > Hi
        > > This small code is troubling me .Trying to assign the value to one hash
        > > variable but its replicating to all ?
        > > am i missing some thing here ...?
        > > #code
        > > #!/usr/bin/perl
        > >
        > > @arrayOfRec;
        > > $rec = {
        > > NAME => "Jason",
        > > AGE => 23,
        > > };
        > > print ($rec->{NAME});
        > >
        > > for($i=0;$i<20;$i++)
        > > {
        > > $rec->{NAME} = "Hello";
        > > $rec->{AGE} = 0;
        > >
        > > push @arrayOfRec, $rec;
        > > }
        >
        > You're pushing 20 copies of the same reference into @arrayOfRec. Change
        > this to
        >
        > for ($i = 0; $i < 20; $i++) {
        > my $rec = { NAME => "Hello", AGE => 0 };
        > push @arrayOfRec, $rec
        > }
        >
        > and you'll be fine.
        also use strict
        kg
      • Raghavendra V. Kulkarni
        Hi! Just wanted to know where can I find source listing of hton/ntohl/htonl functions. Please let me know if there is a URL. Regards, Raghu
        Message 3 of 7 , Nov 6 10:14 PM
          Hi!

          Just wanted to know where can I find source
          listing of hton/ntohl/htonl functions. Please
          let me know if there is a URL.

          Regards,
          Raghu
        Your message has been successfully submitted and would be delivered to recipients shortly.