in reply to What is your Perl dialect?

I like to think that I speak a fairly 5.6 dialect of perl. :-) Some things that I do and dont do are

Im sure there is more to say but I think this is a good place to start...

---
demerphq


• Update:  
dragonchild noticed that I ommitted to call $sub so I added the missing line. Thanks dude.


Replies are listed 'Best First'.
Re: Re: What is your Perl dialect?
by broquaint (Abbot) on Feb 14, 2003 at 14:26 UTC
    * When writing recursive routines I usually use a named wrapper and then an anonymous sub to do the recursion
    <plug>Why, what a perfect situation for Sub::Lexical</plug>
    * I often use pack, as well as s///e
    What situations do you find yourself using s///e? I can't say I've ever used it anything outside golf and obfu so where does it fit into your day-to-day coding?

    _________
    broquaint

      <plug>Why, what a perfect situation for Sub::Lexical</plug>

      *Blush* I have meaning to check that out for a while... Ill have looksee when i get a minute. :-)

      What situations do you find yourself using s///e? I can't say I've ever used it anything outside golf and obfu so where does it fit into your day-to-day coding?

      I do a lot of data transformation type tasks. So it comes in useful quite regularly. Having said that I can't remember exactly where I used it last, but I do recall that I used it fairly recently.

      ---
      demerphq


      • Update:  
      Heres an (untested) simplified example of where s///e comes in useful

      $date=~s/^(\d+)-(\d+)-(\d+)$/sprintf('%04d/%02d/%02d',$1,$2,$3)/e or die "Failed to normalize date...";


Re2: What is your Perl dialect?
by dragonchild (Archbishop) on Feb 14, 2003 at 17:36 UTC
    sub recurse_inorder { my $self=shift; my @inorder; my $sub; $sub=sub{ my $node=shift; $sub->($node->left) if $node->left; push @inorder,$node->value; $sub->($node->right) if $node->right; }; return \@inorder; }
    Maybe I'm just dense, but when does the actual population of @inorder happen?

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

      Maybe I'm just dense, but when does the actual population of @inorder happen?

      Presumably you are refering to the fact that originally I forgot to call $sub. Thanks for the heads up. :-)

      Ive updated the node now. If this isnt what you meant /msg me and Ill update this node with an explanation....

      ---
      demerphq