user-pic

Paul "LeoNerd" Evans

  • Commented on Python's decorators in Perl
    Or you could use an attribute sub p :bold :div_id("testid") { my ($str) = @_; return "$str"; } Attributes can modify the code in-place, and replace it with a wrapped version...
  • Commented on Inheritance is Bad: Code Reuse Part 1
    Your comparison with IO::Seekable as a role is somewhat of a red herring here. The IO::Seekable class exists, not because it's a sensible split in code structure, but purely for social reasons, as it was easier to create a new...
  • Commented on Extracting values from a list of (key, value) pairs
    It's nice to see that pairkeys() is fastest there. As I'd hope it would be, because it's written in XS. It's available on CPAN for current perls and will be in 5.20, so it should be available to anyone other...
  • Commented on Getting a progress report from a running program
    I often use SIGQUIT for this purpose, because by default it's even bound to a key on the terminal - Ctrl-\. This means you can send it to a foreground process without having to kill or pkill from another terminal....
  • Commented on Things we don't have #2
    Given the existence of Net::Async::HTTP, Net::Async::FTP, Net::Async::IMAP::Client, etc.. it should be fairly easily possible to write a universal URL-driven async fetching wrapper, similar to the idea that LWP has of a centralised controller with handlers for various URL schemes. In...
  • Commented on Great Mystic Mystery Revealed
    It was originally a quick, a limit of the parser used to pull out the package names. But so many people have now relied on it, that it's become a feature that won't be fixed....
  • Commented on Anyone else get personal URL from Google Plus?
    On about the first week of G+'s launch, I created myself a named personal URL redirector at http://go.leonerd.org.uk/+ which I've used ever since....
  • Commented on Asynchronous MySQL Queries in Perl Using DBD::mysql and AnyEvent
    If you're going to use this idea, be aware that it's only a half-baked solution. For this to work reliably, the file descriptor itself still needs to be in blocking mode, so that writes and reads to it are not...
  • Commented on CPAN {Spring|Autumn} cleaning time again
    I occasionally find it useful to have the latest-but-one release off CPAN as well. Sometimes the latest release introduces a bug that I can avoid by using the previous release. Personally I tend to keep a rotation of three versions...
  • Commented on Recursive deferred promises
    I should also add: The code block you wrote here has a bug in it. Because the anonymous function contains a reference to itself, it forms a cycle that will never be collected and leak memory. To fix it, you'd...
  • Commented on Recursive deferred promises
    Actually, Future already has a way to handle this very thing. Any sort of while or foreach-type loop can be written using the repeat function in Future::Utils. For instance, in your specific case you have a few command strings to...
  • Commented on The Four Major Problems with CPAN
    As the author of two of the six modules you point out in the first place, I feel I should write a little reply here. As to the Socket vs. Socket6 question: Originally, Socket6 was written by someone to provide...
  • Commented on Perl programmer humour
    I usually end with 0x55AA; http://en.wikipedia.org/wiki/Master_boot_record#Sector_layout...
  • Commented on 13% of CPAN distributions don't have a test report on Windows
    I've already written about the comparative lack of test reports from Windows, as compared other platforms. I'm still not really sure why this is. http://leonerds-code.blogspot.co.uk/2012/07/dear-perl-users-on-windows.html...
  • Commented on 50% of the new CPAN uploads lack a repository link
    I have a different reason here. I actively choose not to include such information. My VCS is much like my editor, my shell, my terminal, or anything else. It's an inner part of the process I use to create the...
  • Commented on The sad state of syntax highlighting libraries on CPAN
    I keep meaning to write an article/example/description/something on how you can use Parser::MGC to parse up the input text and yield a syntax tree annotated to give the positions it found the various constructs in the input. This would make...
  • Commented on How many ways to start a process do you know?
    Don't forget most event systems will probably have their own specific ways as well. POE::Wheel::Run, IO::Async::Process, AnyEvent no doubt will have something too, GLib's gspawn,......
  • Commented on Building C and C++ libraries with Perl
    You might also be interested in ExtUtils::CChecker, for checking system or C library dependencies, and configuring the build system to use them....
  • Commented on AnyEvent::Capture - Synchronous calls of async APIS
    It's basically the same as IO::Async's await method, then. my @ips = $loop->await( $getaddrinfo_task )->get;...
  • Commented on address-sanitizer round 2
    Can you prod me about these on IRC at some point I appear to be free? I now have the power to fix two of them (Socket, List::Util). Thanks :)...
  • Commented on Time for a new Issue Tracker, Isn't It?
    You may find it a foregone conclusion, but for the rest of us, can you summarise what is wrong with rt.cpan.org? I mean I have a tiny gripe about its autocomplete="off" behaviour in the password field, but asides that I...
  • Commented on DateTime is annoying
    A lot of objects with name/value pair constructors often define a simple "80% of the time" use-case for which named argument you'd be wanting to set if you just passed a single one. E.g. IO::Socket::IP presumes a single IP is...
  • Commented on Learning AnyEvent
    Why stop at two event systems? Take a peek also at IO::Async: http://search.cpan.org/dist/IO-Async/ It has a relatively small simple objecty API like AnyEvent, but a bit more structured in things like adding/removing real objects to its control, rather than you...
  • Commented on Activate ipv6 on Windows
    Try IO::Socket::IP instead. It handles IPv4, IPv6, and whatever else may come along in the future, all via the nice forward-compatible magic that is getaddrinfo(). Much nicer than the 'v4-specific ::INET or 'v6-specific ::INET6....
  • Commented on Time spent waiting for tests you know will pass is time wasted
    For installing the same set of stuff across lots of machines I've always found it far nicer to build a debian package out of each CPAN dist, and install those via apt. Tests are run at package build time, not...
  • Commented on My take on Modern Perl
    I have yet to see any type-based optimisations for runtime performance that didn't get in the way of things like object class mocking for unit tests, to take a random example. I like the dynamic nature of perl. I like...
  • Commented on My take on Modern Perl
    Ah; I see. So it's static typing for the purposes of applying optimisations, not for checking program correctness? In that case, why not have the runtime perform JIT-style optimisations as and when it requires, if it determines them to be...
  • Commented on My take on Modern Perl
    The whole "strong typing" slope gets very slippery very quickly. int sub sum(int @values) { ... } Ah. Now I can't sum floats. num sub sum(num @values) { ... } What about objects that overload numerical addition? Now we need...
  • Commented on Ocaml Pet Peeve
    Originally C behaved like this. This is why a lot of the traditional UNIX/POSIX structs have unique prefixes on their member names; for example the st_ prefix on members of struct stat....
  • Commented on I need pack examples for the Camel
    A number of pairs of pack/unpack examples can be found in http://cpansearch.perl.org/src/PEVANS/Tangence-0.07/lib/Tangence/Message.pm...
Subscribe to feed Recent Actions from Paul "LeoNerd" Evans

  • Diab Jerius commented on Extracting values from a list of (key, value) pairs

    @Graham Knop: I've fixed the code; thanks.

    @Aristotle: It actually seems to slow it down by a bit. Sequential runs with with your suggestion implemented, followed by the original code give:

    with: 1002/s 1016/s
    original: 1049/s 1075/s

    The difference between the two is probably significant within the noise of the measurements.

  • mascip commented on Extracting values from a list of (key, value) pairs

    Have you tried Var::Pairs, written by Damian Conway? It doesn't have a subroutine to extract all keys, but it's very god for loops:

    for my $next (pairs @array) {
    say $next->index, ' has the value ', $next->value;
    }

  • Sid Burn commented on Inheritance is Bad: Code Reuse Part 1

    I did not say that IO::Seekable exists or was split because someone had the design in mind that i described here.

    I'm justing saying that the design that i described matches that of IO::Seekable and it is just an example to better understand what i described.

  • Piotr Roszatycki commented on Python's decorators in Perl

    It is true: I could use attributes. Even if some of attribute names are already restricted (lvalue, method, locked, shared and unique).

    But I'm not sure if attributes are lexicaly scoped? I don't want to define "bold" or "div_id" attribute in any module. I want it only in this one module.

  • Toby Inkster commented on Python's decorators in Perl

    Attributes are isa-scoped. So you can define them in package X, and then use them not only in X, but also in any package that inherits from X. (The gotcha is to make sure you declare inheritance at compile-time rather than run-time.)

Subscribe to feed Responses to Comments from Paul "LeoNerd" Evans

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.