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

Re: [PBML] finished... and a thankyou & some thoughts on perl style....

Expand Messages
  • Richard Maynard
    Congrats on getting done what you needed to get done :) Read on for a little inline on the hash stuff... ... Checks to see if a counter is defined for a
    Message 1 of 17 , May 30, 2002
      Congrats on getting done what you needed to get done :)

      Read on for a little inline on the hash stuff...

      > unless(defined($counter{$cat})){
      Checks to see if a counter is defined for a category, if it isn't ...

      > $counter{$cat}=0;
      > $line_counter=$counter{$cat};
      Define the counter for the category you're on, and set the line counter
      equal to this for future manipulation if needed.

      > $cats{$cat}{$line_counter}=$value;
      This is a multi-deminsional hash. You can defined many "sub values" for
      $cats{$cat}. This was just the first thing I thought up when I saw the
      original message. There are probably better ways of putting this stuff
      in the hash, but I've used similar methods, because except in rare cases
      I'm not concerned about how much memory Perl is using on my hashes.

      > else {
      > $counter{$cat}++;
      If the category counter was defined, then increment the counter.

      > $line_counter = $counter{$cat};
      > $cats{$cat}{$line_counter}=$value;
      This sets the hash value to the new "product" name, this might expand to
      look like this:
      $cats{"books"}{"0"}="Squids for Kids"
      $cats{"books"}{"1"}="Whose yer daddy, for pimps"


      As you alluded too, each person has their own coding style, that is unique
      to them, and the code they write. I generally don't take shortcuts. Perl
      offers a lot of shortcuts, and they are very handy. However, some of the
      shortcuts make for very hard to manage code. A small script isn't to bad,
      but when you're dealing with a complex set of interdependant scripts, it
      can be a real nightmare.

      Again, congrats on the bit of code! I know the euphoria that comes with
      the initial launch of something you've written :)

      -Richard
    Your message has been successfully submitted and would be delivered to recipients shortly.