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

yanick opened this Issue Mar 13, 2013 · 5 comments


None yet

4 participants

yanick commented Mar 13, 2013

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.

ghost commented Mar 13, 2013

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

What version of perl?

ghost commented Mar 13, 2013

And what version of Path::Class?

ghost commented Mar 13, 2013

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.


ambs commented Sep 2, 2013

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

xsawyerx commented Sep 2, 2013

@ambs Yup!

@xsawyerx xsawyerx closed this Sep 2, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment