# New Ticket Created by  Fernando Santagata 
# Please include the string:  [perl #127707]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=127707 >


Hello,

I'm experimenting with perl6 and perhaps I hit a bug.
I was trying to move subdirs between two dirs, but my code wouldn't work,
so I tried to find what caused the problem.

The part commented out is what I wrote at first, the line marked with a
"this" comment is what is not working in my opinion. The pod document shows
the directory layout of my little experiment.

#!/usr/bin/env perl6

=begin pod

.
├── base
│   ├── a
│   └── b
├── other
│   ├── a
│   │   └── a
│   ├── b
│   │   └── b
│   └── c
│       └── c
└── test.p6

=end pod

constant $base  = 'base';
constant $other = 'other';

my @base  = dir($base)».basename.sort;
my @other = dir($other)».basename.sort;
my $common = @base ∩ @other;
#@other.map( -> $dir
#  {
#    if $dir ∈ $common {
#      dir("$other/$dir")».basename.map( -> $file { try { rename
"$other/$dir/$file", "$base/$dir/$file"; } } );
#    } else {
#      rename "$other/$dir", "$base/$dir";
#    }
#  } );
@other.map( -> $dir
  {
    if $dir ∈ $common {
      say "$dir common";
      my @files = dir("$other/$dir")».basename;
      @files.map(-> $file { say "$other/$dir/$file" } ); # <-- this
    } else {
      say "rename $other/$dir, $base/$dir";
    }
  } );

Using rakudo 2016.02, the @files.map() line produces no output, while all
the other say() work fine.

A simple program like the following:

#!/usr/bin/env perl6
my @files = dir("other/a")».basename;
@files.map(-> $file { say "other/$file" } );

works fine, so I guess that the .map() has no problem when is been executed
by itself and the problem shows up just when it's inside another .map().

Thank you for your work on Perl6!

-- 
Fernando Santagata

Reply via email to