Skip to content


dancer2 attempting to use references as an lvalue in a substitution #213

yanick opened this Issue · 5 comments

4 participants


Moving a Dancer2 issue off the Dancer1 issue list. PerlDancer/Dancer#881

From the original:

I just tried to test out dancer2:

$ dancer2 --app-mode distzilla --app jobgui
Creating app : jobgui
Attempt to use reference as lvalue in substr at /home/houghton/perl5/lib/perl5/App/ line 129.

Here's the relevant bit of code in App::Dancer2:

sub _copy_dist {
    my ( $self, $from, $to ) = @_;
    my $app          = $self->app;
    my $now          = DateTime->now();
    my $current_year = $now->year;
        callback => sub {
            my $child = shift;
            my $dest = dir( $to, substr( $child, length($from) ) ); # where's the lvalue? $dest?
            $dest =~ s/\Q[%APP%]\E/$app/gx;                         # here's the substitution

I tried to recreate the bug simply by messing with substr.

$ perl -E 'package foo; sub new {bless {}}; say "quux" . substr(foo->new, length(foo->new)) . "bar"'

No luck. Is the problem with the next line?

$ perl -MPath::Class -E '$v = dir("ab"); $v =~ s/^./x/; say $v'

So I'm no help. Anyway, the dancer2 app failed to create anything. I hope you can sort this out.


I was not able to replicate this. The dancer2 app worked for me with the same command line options.

What version of perl?


And what version of Path::Class?


Replicated on 5.12.4.

It's sufficient to pull the substr out to a separate lexical rather than putting it in the constructor to dir()

        my $subdir = substr( $child, length($from) );
        my $dest = dir( $to, $subdir );

Separately, I don't think s/// does anything when applied to a Path::Class object. It will stringify, the string will be modified, then thrown away. Nor am I clear if the regex ever matches.

So something is rotten in the state of Denmark.



This is about App::Dancer2, not Dancer2 itself. Shouldn't we just close this issue? @xsawyerx?


@ambs Yup!

@xsawyerx xsawyerx closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.