fishy has asked for the wisdom of the Perl Monks concerning the following question:

Hi Monks,
I have some trouble with the following code:
use strict; use List::Util qw(shuffle); my @train = (1, 2, 3, 4, 1, 2, 4, 4, 1, 2, 3, 4, 1); my @test = shuffle @train; # my @test = @train;
Running it with "perl -d:DProf" I get the following error message: "Modification of a read-only value attempted at - line 4." Commenting out the offending line, no error but no shuffled list. With just "perl -w" everything is fine. I get a shuffled list without error.
It seems to me that the func "shuffle" is not profiler friendly.
Curiousity: I'm on Win32 with ActiveState 5.8.8 build 822. With ActiveState 5.8.8 build 820 I can run it with "perl -d:DProf" getting a shuffled list without error message.
Any hint?
Thanks in advance.

Replies are listed 'Best First'.
Re: Profiling with List::Util qw(shuffle)
by andreas1234567 (Vicar) on Jun 10, 2008 at 11:06 UTC
    I get a panic when I run the above code with perl 5.8.5. It works, however, with perl 5.10.0:
    $ uname -srpio Linux 2.6.9-55.0.12.EL i686 i386 GNU/Linux # List::Util is up to date (1.19). $ perl5.8.5 -d:DProf -w use strict; use List::Util qw(shuffle); my @train = (1, 2, 3, 4, 1, 2, 4, 4, 1, 2, 3, 4, 1); my @test = shuffle @train; __END__ panic: pad_sv po at - line 4. $ perl5.10.0 -d:DProf -w use strict; use List::Util qw(shuffle); my @train = (1, 2, 3, 4, 1, 2, 4, 4, 1, 2, 3, 4, 1); my @test = shuffle @train; __END__
    --
    No matter how great and destructive your problems may seem now, remember, you've probably only seen the tip of them. [1]
Re: Profiling with List::Util qw(shuffle)
by cdarke (Prior) on Jun 10, 2008 at 12:26 UTC
Re: Profiling with List::Util qw(shuffle)
by moritz (Cardinal) on Jun 10, 2008 at 11:00 UTC
    Seems like a bug in your activeperl version. It runs fine with 5.8.8, 5.10.0 and blead on linux.
Re^2: Profiling with List::Util qw(shuffle)
by tinita (Parson) on Jun 10, 2008 at 11:49 UTC

    I also get the error message:
    Modification of a read-only value attempted at -e line 5.
    This is perl, v5.8.8 built for i486-linux-gnu-thread-multi

    edit: actually wanted to reply to the original posting.

Re: Profiling with List::Util qw(shuffle)
by syphilis (Archbishop) on Jun 10, 2008 at 12:11 UTC
    Modification of a read-only value attempted at - line 4

    Yep - I get the same on build 822. Rolling back from version 1.19 to version 1.18 of Scalar-List-Utils fixes the problem for me - though version 1.19 seems to work ok on AS build 1003 (5.10.0).

    Cheers,
    Rob
Re: Profiling with List::Util qw(shuffle)
by linuxer (Curate) on Jun 10, 2008 at 12:10 UTC

    No errors here with Activestate 5.8.8 build 817 on WinXP;

    edit: $List::Util::VERSION is 1.18;

Re: Profiling with List::Util qw(shuffle)
by cdarke (Prior) on Jun 10, 2008 at 12:17 UTC
    No errors on "This is perl, v5.8.8 built for i386-linux-thread-multi" (CentOS).
Re: Profiling with List::Util qw(shuffle)
by magnifico18 (Initiate) on Jun 10, 2008 at 18:54 UTC
    I had this problem a few weeks back. I think I worked around it by using Devel::Profiler instead of DProf. Edit: I was using Strawberry Perl, by the way. So this problem is not restricted to a specific build of ActiveState Perl.