in reply to Multiple routes that execute the same action

People using Moose sometimes forget that Moose is still Perl. They need to do something unusual; something outside the bounds of what Moose has sugar for, and they forget that they've still got the rest of Perl at their disposal, and what they want to do is actually pretty easy.

Now it seems that Dancer has the same problem. What you want is to do is actually pretty easy. Don't forget you have all of Perl at your disposal, including, (shock!) variables that you can, like, assign stuff to, and then, like, re-use in multiple places...

{ my $code = sub { ... }; my @paths = qw( /myaction1/:param1 /myaction2/:param2 ); get($_, $code) for @paths; }
use Moops; class Cow :rw { has name => (default => 'Ermintrude') }; say Cow->new->name

Replies are listed 'Best First'.
Re^2: Multiple routes that execute the same action
by McA (Priest) on Mar 28, 2014 at 12:40 UTC

    Hi Tobyink,

    this is a very interesting point. This would mean IMHO that the documentation for a DSL should also show what is done behind the scene and that a DSL construct is "just" syntactic sugar. But often exactly this is not intended because the DSL should hide implementation to force a kind of thinking or working.

    Or do you think that a "user" should take the time to look what is done with the DSL constructs?

    Regards
    McA

Re^2: Multiple routes that execute the same action
by perl_help26 (Beadle) on Mar 28, 2014 at 13:19 UTC

    Thank you that's great!