$DB::single = 1 : Make that debugger stop where you want it

Sometimes it’s useful to get a perl debugger to stop exactly where you want it to stop.

When debugging on the command line I’ve got a relatively manual process of bringing up a debugger, use-ing my module of choice if it’s not already loaded, breaking at a method name, continuing, then breaking at the line I want. It’s likely there is a better way to do this, but I haven’t found it yet because I usually just insert a

$DB::single = 1;

expression exactly where I want it.

I’m sure most people know about this, but if you don’t, take a look at

$ perldoc perldebug

and pay attention to the section describing

$DB::single = 1;

Inserting that expression will make the perl debugger stop on that line when it’s reached. You can just fire up your program or test case in the debugger and let it run.

Also useful could be wrapping that statement in a condition that checks for your particular case or iteration.

The perl debugger is filled with other great magic, but I find $DB::single is a feature I use often.

 

 

 

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

OSX Package for Padre 0.92

I’m happy to provide the osx dmg for the latest Padre Perl IDE release, 0.92. The march to 1.0 continues thanks to the great work done by the Padre team! As usual, I used the Cava Packager to bundle the CPAN Padre with a few core plugins.

Please check this page for the latest package, and info on how to report bugs.

We would appreciate any testing you do on OSX, and please report bugs you run into. Why not stop by #padre and say hi while you download?

Note: Padre on OSX still has a number of rough edges.

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

printing lists versus concat strings? a little nibble of a benchmark

Please check out the comments to see more information about this topic.

Going to put this out there because I saw some code the other day that printed comma separated strings and scalars, and it got me curious about how expensive it was to print a list of items, rather than concatenating them into a string and passing that to print.

I’ll let the code speak for itself:

 my $x = 'test';
 my $r = timethese(
 10000000,
 { 
 'commaprint'    => sub { print STDERR 'test', 'test', 'test', 'test', 'test', 'test'; },
 'varcommaprint' => sub { print STDERR $x, $x, $x, $x, $x, $x; },
 'interpprint'   => sub { print STDERR "$x $x $x $x $x $x"; },
 'concatprint'   => sub { print STDERR 'test' . 'test' . 'test' . 'test' . 'test' . 'test'; }, 
 'singleprint'   => sub { print STDERR 'test'; },
} );

And the result on my laptop:

commaprint: 33 wallclock secs (12.46 usr + 19.77 sys = 32.23 CPU) @ 310269.93/s (n=10000000)
varcommaprint: 32 wallclock secs (12.76 usr + 19.74 sys = 32.50 CPU) @ 307692.31/s (n=10000000)
interpprint: 10 wallclock secs ( 7.44 usr +  3.68 sys = 11.12 CPU) @ 899280.58/s (n=10000000)
concatprint:  6 wallclock secs ( 3.02 usr +  3.58 sys =  6.60 CPU) @ 1515151.52/s (n=10000000)
singleprint:  6 wallclock secs ( 2.97 usr +  3.52 sys =  6.49 CPU) @ 1540832.05/s (n=10000000)

I’m not completely surprised by the result, but I would’t want to speculate about what’s going on under the covers without spending time studying the perl code. For now this will just have to leave this out there as something to consider in the future.

 

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

Padre 0.90 OSX dmg

I’m happy to provide the osx dmg for the latest Padre Perl IDE release, 0.90. The march to 1.0 continues thanks to the great work done by the Padre team!

Please check this page for the latest package, and info on how to report bugs.

We would appreciate any testing you do on OSX, and please report bugs you run into. Why not stop by #padre and say hi while you download?

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

Padre 0.88 OSX dmg

I’m happy to announce that Padre 0.88 is available as an OSX dmg.

Along with all the amazing work Padre folks have been doing to release 0.88, we’ve also been hunting down critical OSX bugs that surfaced during the recent weeks.

There is some more TLC that needs to be given to the Padre codebase for OSX. Thus, along with the known OSX defects, I anticipate we’ll continue to find more issues that need fixing.

That’s why we need you to try the Padre 0.88 dmg, and let us know if you have any issues, crashes, or feature requests. I hope Padre on OSX will be on par with linux and windows by the 1.0 release with your help.

Bug reports can be made most easily by hopping into #padre on irc, or even commenting on this blog post.

Thanks:
I want to thank Mark for doing the work to develop the packaging project for Padre using Cava, and for his help with some of the gnarly issues I ran into these past weeks.

Also, thanks to the folks who reported bugs in the 0.86 dmg (that have been solved I hope), and to everyone on #padre.

Want to run Padre on OSX from source?
You can use the bin/padre-brew.pl script found in the padre-brew github to create a perl+padre on OSX.

If you’re on windows or linux, see the 0.88 release announcement.

 

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

padre-brew now supports OSX LION (Build your own Padre on OSX)

My padre-brew script, which creates a standalone version of perl (32 bit) + wxWidgets + Padre, has been updated to support OSX Lion. Currently it supports OSX out of the box, and does work on Linux though you’ll need to get wxWidgets working your system first.

You can have a look at the github here: http://bit.ly/oiME1I

If you want to try Padre on OSX (warts and all, we’ve got a long way to go on OSX), all you need to do is grab the source and run:

./bin/padre-brew.pl --no-test

That will create a PadreApp directory, with a padre script you can run. As always thanks to Mark @ Cava for doing all the hard work to get all the build flags, etc. All mistakes are my own.

Tom

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

Padre on OSX DMG – Now on Leopard, Snow Leopard, and Lion

Please use the 0.88 DMG.

Below is the old 0.86 post for reference.


Thanks to Mark @ Cava for giving me the perl build line needed to produce Padre packages that work on the latest three OSX versions.

You can now grab the latest OSX Padre packages (0.86) with a few plugins embedded, at:

http://wildperl.com/wp-content/uploads/Padre/0.86/padre-osx-uni-0-86-0.dmg

I plan to post a complete ‘how go build and package Padre on OSX’ post (and/or wiki page on Padre trac) as soon as I update my padre-brew.pl tool for Lion.

If you’re interested, I now build perl with this command:

perlbrew install 5.14.1 -ders -Dusethreads -Duseithreads -Accflags="-arch i386" -Accflags="-B/Developer/SDKs/MacOSX10.6.sdk/usr/include/gcc" -Accflags="-B/Developer/SDKs/MacOSX10.6.sdk/usr/lib/gcc" -Accflags="-isystem/Developer/SDKs/MacOSX10.6.sdk/usr/include" -Accflags="-F/Developer/SDKs/MacOSX10.6.sdk/System/Library/Frameworks" -Accflags="-mmacosx-version-min=10.5" -Aldflags="-arch i386 -Wl,-search_paths_first" -Aldflags="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk" -Aldflags="-mmacosx-version-min=10.5" -Alddlflags="-arch i386 -Wl,-search_paths_first" -Alddlflags="-Wl,-syslibroot,/Developer/SDKs/MacOSX10.6.sdk" -Alddlflags="-mmacosx-version-min=10.5" -Duseshrplib

And I configure and build Alien::wxWidgets and Wx::Scintilla with the following build:

CFLAGS='-arch i386' CXXFLAGS='-arch i386' CPPFLAGS='-arch i386' LDFLAGS='-arch i386' OBJCFLAGS='-arch i386' OBJCXXFLAGS='-arch i386' perl ./Build --wxWidgets-extraflags=" --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.5 " --wxWidgets-build='yes' --wxWidgets-source='tar.bz2' --wxWidgets-version=2.8.12

If you have bugs, please file them in track: http://padre.perlide.org/trac/wiki/osxbugs

All errors are my own.

Thanks!

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

Padre DMG for OSX Lion – alpha build

With great pleasure I can finally announce that we’ve got OSX Lion builds for Padre!

You can grab the latest here: http://wildperl.com/wp-content/uploads/Padre/0.86/padre-osx-uni-0-86-0-LION.dmg

Getting reliable packages for Padre on OSX has been my goal for the past few weeks, and these have surfaced a number of OSX bugs that have not yet been adressed.

You can find a list of current defects (and open your own) here: http://padre.perlide.org/trac/wiki/osxbugs

My work was really that of glue-er, and it would have been impossible if not for the real heavy lifting done by Mark @ Cava who built the packaging scripts we use, and Cava, and also supported wxwidgets building on Lion.

We are using Cava to package on OSX at the moment (and potentially other platforms in the future).

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

wxwidgets 2.8.12 (and Alien::wxWidgets) on OSX Lion

I can finally make this a short post!

I was able to combine the advice found in this post http://wiki.wxwidgets.org/Development:_wxMac  and some messages from the gurus on the wxPerl mailing list to other Lion builders.

To build Alien::wxWidgets 2.8.12, as well as (and this was the crux) Wx::Scintilla, on OSX 10.7 (Lion), I’m using:

CFLAGS='-arch i386' CXXFLAGS='-arch i386' CPPFLAGS='-arch i386' LDFLAGS='-arch i386' OBJCFLAGS='-arch i386' OBJCXXFLAGS='-arch i386' perl Build* --wxWidgets-extraflags=" --with-macosx-sdk=/Developer/SDKs/MacOSX10.6.sdk --with-macosx-version-min=10.6 " --wxWidgets-build='yes' --wxWidgets-source='tar.bz2' --wxWidgets-version=2.8.12

*For simplicity I use the same environment and arguments for the ./Build.PL and ./Build step

Note a few things:

  1. I am using a 32 bit perl (info below) because I am using wx 2.8.12
  2. Thus I must include all those -arch prefixes when building (see link above)
  3. I set the Min version to 10.6, though I have only been able to test on 10.7
  4. The same flags must be used for wx-things like Wx::Scintilla – in my semi-automated build I drop into a cpanm –look to build these right now, but I hope to include them into my padre-brew.pl script shortly.

 

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon

WWW::Mixpanel Updated v0.02 – Date Api support

I recently released WWW::Mixpanel v0.02, with added support for the Mixpanel Data API. We’ve been using Mixpanel for a few weeks and have been happy with the interface and the ease of integration. Hope this perl module helps others get started with the service.

WWW::Mixpanel can be reached on CPAN or github.

NAME
    WWW::Mixpanel

VERSION
    version 0.02

SYNOPSIS
      use WWW::Mixpanel;
      my $mp = WWW::Mixpanel->new( '1827378adad782983249287292a', 1 );
      $mp->track('login', distinct_id => 'username', mp_source => 'twitter');

    or if you also want to access the data api

      my $mp = WWW::Mixpanel->new(<API TOKEN>,1,<API KEY>,<API SECRET>);
      $mp->track('login', distinct_id => 'username', mp_source => 'twitter');
      my $enames = $mp->data( 'events/names', type => 'unique' );
      my $fdates = $mp->data( 'funnels/dates',
                     funnel => [qw/funnel1 funnel2/],
                     unit   => 'week' );

DESCRIPTION
    The WWW::Mixpanel module is a young implementation of the
    <http://mixpanel.com> API which provides realtime online analytics.
    <http://mixpanel.com> receives events from your application's perl code,
    javascript, email open and click tracking, and many more sources, and
    provides visualization and publishing of analytics.

    Currently, this module mirrors the event tracking API
    (<http://mixpanel.com/api/docs/specification>), and will be extended to
    include the powerful data access and platform parts of the api. FEATURE
    REQUESTS are always welcome, as are patches.

    This module is designed to croak on failure, please use something like
    Try::Tiny.

METHODS
  new( $token, [$use_ssl] )
    Returns a new instance of this class. You must supply the API token for
    your mixpanel project. HTTP is used to connect unless you provide a true
    value for use_ssl.

  track('<event name>', [time => timestamp, param => val, ...])
    Send an event to the API with the given event name, which is a required
    parameter. If you do not include a time parameter, the value of time()
    is set for you automatically. Other parameters are optional, and are
    included as-is as parameters in the api.

    This method returns 1 or croaks with a message.

    Per the Mixpanel API, a 1 return indicates the event reached the
    mixpanel.com API and was properly formatted. 1 does not indicate the
    event was actually written to your project, in cases such as bad API
    token. This is a limitation of the service.

    You are strongly encouraged to use something like "Try::Tiny" to wrap
    calls to this API.

    Today, there is no way to set URL parameters such as ip=1, callback,
    img, redirect. You can supply ip as a parameter similar to distinct_id,
    to track users.

  data('<path/path>', param => val, param => val ...)
    Obtain data from mixpanel.com using the Data API
    <http://mixpanel.com/api/docs/guides/api/v2>. The first parameter to the
    method identifies the path off the api root.

    For example to access the "events/top" functionality, found at
    <http://mixpanel.com/api/2.0/events/top/>, you would pass the string
    "events/top" to the data method.

    Some parameters of the data api are of array type, for example
    "events/retention" parameter "event". In every case where a parameter is
    of array type, you may supply the parameter as either an ARRAYREF or a
    single string.

    Unless specified as a parameter, the default return format is json. This
    method will then return the result of the api call as a decoded perl
    object.

    If you specify format => 'csv', this method will return the csv return
    string unchanged.

    This method will croak on errors, including malformed parameters,
    indicated by bad return codes from the api. It croaks with the text of
    the api reply directly, often a json string indicating which parameter
    was malformed.

    *To see all API methods at work, look into the module tests.*

TODO
    /track to accept array of events
        Track will soon be able to accept many events, and will bulk-send
        them to mixpanel in one call if possible.

    /platform support
        The Platform API will be supported. Let me know if this is a feature
        you'd like to use.

FEATURE REQUESTS
    Please send feature requests to me via rt or github. Patches are always
    welcome.

BUGS
    Do your thing on CPAN.

AFFILIATION
    I am not affiliated with mixpanel, I just use and like the service.

AUTHOR
    Tom Eliaz

COPYRIGHT AND LICENSE
    This software is copyright (c) 2011 by Tom Eliaz.

    This is free software; you can redistribute it and/or modify it under
    the same terms as the Perl 5 programming language system itself.

Post to Twitter Post to Digg Post to Facebook Send Gmail Post to LinkedIn Post to Reddit Post to StumbleUpon