my $x = ones(25); $x->hdr->{demo} = "yes"; say $x->info; # PDL: Double D [25] say $x->sum; # 25 say $x->hdr->{demo} ? "exists" : "NOT FOUND"; # here it's OK $x->reshape(5,5); say $x->info; # PDL: Double D [5,5] say $x->sum; # 25 say $x->hdr->{demo} ? "exists" : "NOT FOUND"; ### item does not exist!!!!!
It appears that reshape() makes pdl of the input argument with pdl(). If this is replaced by PDL::Core::topdl() instead then the hdr appears to be preserved. pdl() makes a copy which is where the hdr is dropped.
I have pushed the fix you have proposed to branch
kmx-fix-for-SF#398
Fixed in git master and will appear in next CPAN release.