Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.
  • sub parse {
        my $feed = XML::Feed->parse(\shift->get_content);
        { feed_title => $feed->title,
          items => [
              map {
             {title => $_->title,
              link => $_->link,
              description => $_->content->body || $_->summary->body,
              date => $_->issued || $_->modified,
     
    • ew! Implicit return? You wouldn't have added an extra line by adding in those 6 letters; but you would have improved readability a fair bit. With what you've written I have to skim to the end to see what you're returning and then work my way upwards to see where the last statement starts. That might be okay when golfing, but that doesn't appear to be your intent. Damian spends almost 3 whole pages on the evils of implicit returns in "Perl Best Practices". See 197-199.

      Otherwise, well down on shrinki

      • I tend to write in an expression-oriented style, e.g. "map" instead of "foreach", and implicit return fits right in. I also try to limit vertical whitespace in order to fit more stuff on the screen. Both are just a matter of taste, though.

        I haven't read PBP, but from what I've heard about it, the "best practice" seems to be to ignore it. It has a few bits of good advice, but most seems arbitrary or just plain wrong.

        • You shouldn’t judge a book by its critics.

          Almost everyone who passes comment on the book seems to have read right past the first chapter where Damian explains that what’s important is not to follow his mandates, but to read the arguments and think about them. The book’s goal is not to get you to write code the way Damian tells you to, but to get people to consciously reflect on their own tastes and proclivities to analyse the impacts of their own choices, particularly as they relate to eac