user-pic

Peter Sergeant

  • About: I blog about Perl.
  • Commented on [FB]izzBuzz in Perl
    Slightly longer and uglier, no warnings: say((('Fizz')[$_%3]||'').(('Buzz')[$_%5]||'')or$_) for 1..100;...
  • Commented on [FB]izzBuzz in Perl
    As someone else has pointed out, brevity is not necessarily what you want to be optimizing for. That said: say(('Fizz')[$_%3].('Buzz')[$_%5]or$_) for 1..100; Throws warnings, though....
  • Posted MooseX::Params::Validate to Peter Sergeant

    Subroutines that take more than a single argument should really be using something like MooseX::Params::Validate.

    Consider:

    sub vivisect { 
    my ( $self, $args ) = @_;
    confess 'Ex…

  • Posted Sequences, Sets, Bags, Functions to Peter Sergeant

    Groups of Items

    A sequence is an ordered list of items, whose items aren't necessarily unique. Perl's arrays are sequences of a finite size:

    my @sequence = qw/bar baz ban baz baz/;

    A set, however, is an uno…

  • Commented on De Morgan's laws in Perl
    Steven: Erlang's `and` and `or` don't short-circuit - instead `andalso` and `orelse` must be used....
  • Posted De Morgan's laws in Perl to Peter Sergeant

    We've been simplifying some ugly code recently, and De Morgan's laws have come up more than once. A developer on the team complained the Wikipedia entry obscured - from a developer's perspective - the simplicity of these quite useful transformation rules, so, expressed in Perl:

    Given $…

  • Commented on Agile Companies?
    One of my clients, NET-A-PORTER, strongly embraces Agile development - all development projects have a backlog, scrums, product owner, agile project manager, etc, and run in such a way that it seems to help rather than hinder. They've even started...
  • Posted New Project: ziprip.js to Peter Sergeant

    I've been playing with JS a bit recently, and have released a client-side library for extracting postal addresses and geocoords from webpages - it's intended for use in bookmarklets and browser extensions:

    http://zipripjs.com/

    I've also made it wo…

  • Commented on Introducing Class::ConfigHash
    Class::ConfigHash : 0.0000072s per lookup Dancer::Config::Object: 0.0000015s per lookup Direct lookup : 0.0000003s per lookup So Dancer::Config::Object is also faster, assuming your config hash won't change once loaded....
  • Commented on Introducing Class::ConfigHash
    There are a few differences, but the most interesting to the end user is probably that Class::ConfigHash doesn't rely on having Dancer installed ;-) From a feature perspective, Class::ConfigHash allows you to have default values, or specify that certain paths...
  • Posted Introducing Class::ConfigHash to Peter Sergeant

    A while ago I saw a post by Ovid on boxing hashes for configuration in Dancer. The idea seemed pretty neat, and I found myself doing something similar in some work for

  • Posted Introducing Template::Plugin::StashValidate to Peter Sergeant

    I've been using MooseX::Params::Validate more and more recently for checking incoming parameters. I'm a big fan of the Moose type system, and love the implicit documentation you get from having a block at the top of…

  • Commented on Behavior Driven Development in Perl
    Hi Al, I'm curious as to why you started your own Cucumber implementation - were there features missing from Test::BDD::Cucumber you were relying on?...
  • Commented on Behavior Driven Development in Perl
    Hi Tudor, I'm glad you're enjoying using Test::BDD::Cucumber! Please let me know how you get on, and which features you're interested in - at the moment, development is very much driven by what people are missing. I've added tag support...
  • Posted Perl and Cucumber to Peter Sergeant

    On one hand, I love getting bug reports for my Cucumber on Perl distro - it means people are using it, which is nice. On the other hand, I wish I hadn't but the bugs in in the first place...

  • Commented on Test::Builder2 vs CPAN and How You Can Help
    I recently had to update two of my modules to deal with TB2. I was alerted to this by a CPAN smoker using it, which was helpful... You can see what I was doing in TB1, compared to what I...
  • Posted Estimating Like an Adult - Part 2 to Peter Sergeant

    I wrote the followup to my last article on estimating - you can see it here: Estimating like an Adult - What to Steal from Agile

  • Posted How to Estimate like an Adult to Peter Sergeant

    New post on my Software Engineering blog: How to Estimate like an Adult

  • Posted Testing Updates to Peter Sergeant

    Test::More::Prefix works with new Test::Builder

    One of the CPAN testers appears to have picked up that there's a n…

  • Commented on How should a JSON parser handle character strings?
    Ben, I think we are at an impasse here. Your position is that as you can handle character strings in a way that doesn't cause data corruption, then you should - that as the parse operation is going to perform...
  • Commented on How should a JSON parser handle character strings?
    Sure, Let's say you have a junior developer working on a web development project using Catalyst. Another developer has installed a plugin which automatically encodes and decodes UTF-8 on the incoming and outgoing, because it seemed like a good idea....
  • Commented on How should a JSON parser handle character strings?
    Ben, Just because it's a well-formed Perl variable doesn't make it valid JSON. Because JSON has a defined (and required) encoding, where Perl character strings don't. To be in a position where you are parsing a "JSON string" that is...
  • Commented on How should a JSON parser handle character strings?
    Why did you post this here? If you're insinuating I'm getting something confused, could you explain what?...
  • Commented on How should a JSON parser handle character strings?
    "Literal Unicode strings in your Perl code will be in Perl internal format if you use utf8 and UTF-8 encoded otherwise." Yes. That's why I used the 'use utf8;' pragma. So that I'd get character strings in Perl's internal format....
  • Commented on How should a JSON parser handle character strings?
    Rick: what I'm confusing here? The point is that character strings with high code points should not be parseable as JSON....
  • Commented on How should a JSON parser handle character strings?
    Ben: if you don't throw a fatal error with a character string with high codepoints, you're doing it wrong. As you quote from the spec, JSON is encoded as UTF-whatever: this means there is no possible 'right' behaviour when encountering...
  • Posted How should a JSON parser handle character strings? to Peter Sergeant

    How should a JSON parser handle character strings with non-ASCII characters? My humble opinion: fatal error. Here's what the JSON parsers on my machine did:

    http://pastebin.com/mwui3iDy

  • Posted Agile Scrum: Delivering Broken Software Since 1991 to Peter Sergeant

    I've added a new article to my software-development / testing blog, called: Agile Scrum: Delivering Broken Software Since 1991 - looks at how Scrum can get subverted, and how to fix it. Enjoy!

  • Commented on Test::BDD::Cucumber
    I'm not sure you need to choose between one or the other - Test::BDD::Cucumber is designed to work in conjunction with Test::More and the other Test::Builder modules... I've started to see Cucumber primarily as a way of organizing tests. As...
  • Posted Test::BDD::Cucumber to Peter Sergeant

    Today on the way to work I almost finished off Test::BDD::Cucumber, but didn't quite manage it. So work having finished, I cracked out my MacBook Air and put the finishing touches in!

    Choose your own adventure: if your reaction was:

    WTF is Cucumber? - ="http…

Subscribe to feed Recent Actions from Peter Sergeant

  • coke commented on [FB]izzBuzz in Perl

    More p5 & p6 versions at Rosetta Code -

    http://rosettacode.org/wiki/FizzBuzz#Perl

  • Toby Inkster commented on [FB]izzBuzz in Perl

    Slightly shorter and uglier with no strict subs:

    say((Fizz)[$_%3].(Buzz)[$_%5]or$_)for 1..100;
    
  • curtis commented on [FB]izzBuzz in Perl

    Yes, I would much prefer someone writing clean code to do this in an interview, but I needed to scratch an itch.

    Wow, I suspected concatenation was the key to getting a shorter line, but did not know how to implement it until now. Thanks all for the replies.

  • Toby Inkster commented on [FB]izzBuzz in Perl

    I was trying something different here. Didn't work out as concise as I'd hoped, but it's pretty cute...

    say+(Fizz,Buzz,FizzBuzz,$_)[substr+233031033013033,$_%15,1]for 1..100;
    

    Along similar lines; a little shorter...

    say+($_,Fizz,Buzz,FizzBuzz)[!($_%3)+2*!($_%5)]for 1..100;
    
  • Michał Wojciechowski commented on [FB]izzBuzz in Perl

    I'm late to the party, but here's my version, using a slightly different approach:

    say+(Fizz)[++$_%3].Buzz x/.?[50]$/||$_ until$`

Subscribe to feed Responses to Comments from Peter Sergeant

About blogs.perl.org

blogs.perl.org is a common blogging platform for the Perl community. Written in Perl and offering the modern features you’ve come to expect in blog platforms, the site is run by Dave Cross and Aaron Crane, with a design donated by Six Apart, Ltd.