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

I have a problem with the following code snippet:
sub jil { my ($self) = @_; my $outstr = $self->_jilout('insert_job') . $self->_jilout('job_type'); $outstr .= $_ foreach (map $self->_jilout($_), @{%$self}{@{$self-> +{_fields_in_seq}}}); $outstr; } sub _jilout { my ($self,$attr) = @_; return '' if !exists($self->{$attr}) || !defined$self->{$attr}; "$attr: ".$self->{$attr}."\n"; }
When I use $foo->jil, I get the 'insert_job' and 'job_type' instructions, but nothing else, no warnings either. Using the Perl 5 debugger gives me a literally bizarre message:
DB<2> c Bizarre copy of HASH in leave at Autosys.pm line 88. ______________________________________________________________________ +________ Exit Code = 0 ______________________________________________________________________ +________ Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. DB<2>
The horizontal rules and 'Exit code = 0' are from the application's END routine. $foo contains:
DB<2> x $_ 0 Autosys::command=HASH(0x4019d918) '_fields_in_seq' => ARRAY(0x4019d93c) 0 'command' 1 'machine' 2 'permission' 3 'alarm_if_fail' 4 'profile' 5 'condition' 6 'box_name' 'alarm_if_fail' => 1 'box_name' => 'OR_D_ID_ENR_RUL_BOX' 'command' => 'run_script.ksh ost_rules.ksh -s FDR -e Stan_Raw_Adjus +t -B100000' 'condition' => 'success(OR_D_ID_ADJUST_ENR)' 'insert_job' => 'OR_D_ID_ADJUST_RULE' 'job_type' => 'c' 'machine' => 'fpdbln99' 'permission' => 'gx' 'profile' => '.auto_profile' DB<3>
Any monks care to shed any light on what is happening. Maybe I need more coffee.

--rW

Replies are listed 'Best First'.
Re: Bizarre copy of HASH in leave
by broquaint (Abbot) on Jul 09, 2002 at 10:43 UTC
    Having put the code in a small test program there's nothing obviously 'bizarre' about it running under v5.6.1
    package rincewind; sub new { bless {}, shift } sub jil { my ($self) = @_; my $outstr = $self->_jilout('insert_job') . $self->_jilout('job_type'); $outstr .= $_ foreach map $self->_jilout($_), @$self{ @{$self->{_fields_in_seq}} }; $outstr; } sub _jilout { my ($self,$attr) = @_; return '' if !exists $self->{$attr} or !defined $self->{$attr}; "$attr: ".$self->{$attr}."\n"; } package main; use strict; use warnings; use Data::Dumper; my $o = rincewind->new; @$o{qw/insert_job job_type/} = qw[ 50 daemon ]; my @flds = qw[ foo bar baz quux ]; @$o{ @flds } = reverse @flds; @{ $o->{_fields_in_seq} } = @flds; print $o->jil, $/; exit 0; __output__ insert_job: 50 job_type: daemon quux: foo baz: bar bar: baz foo: quux
    I can't see any attempts to copy an internal variable that isn't copyable[1]. Maybe some version info would help?
    HTH

    _________
    broquaint

    [1] paraphrased from perldiag

      broquaint, Thanks for your help.

      Your simplification of my somewhat convoluted expression caused the bizarreness to go away (caffeine deficit on my part).

      map $self->_jilout($_), @$self{ @{$self->{_fields_in_seq}} };
      behaves as expected. My perl version is 5.6.1 BTW.
Re: Bizarre copy of HASH in leave
by Abigail-II (Bishop) on Jul 09, 2002 at 11:18 UTC
    As man perldiag would have told you, this message is an internal error message. You should never see it - if you do (and unfortunally, this one pops up every now and then) it's the fault of perl, not your code.

    Try downloading the newest development version of perl (5.8.0-RC2). If you still get the error, try to trim down your program as much as possible and submit a bugreport. If you don't get the error, it was already fixed.

    Abigail