in reply to Re: Re: Re: Dynamically allocating variables
in thread Dynamically allocating variables

Thanks for clarifying that Fastolfe. But, I guess my original question still stands. Without turing strict off, I can't really load a Hash with unique structs that are created on the fly as I read each line in. true or not true?
  • Comment on Re: Re: Re: Re: Dynamically allocating variables

Replies are listed 'Best First'.
Re (tilly) 5: Dynamically allocating variables
by tilly (Archbishop) on Dec 02, 2001 at 11:13 UTC
    I have a feeling that you and Fastolfe are talking past each other.

    The answer is that you can. He is using anonymous hashes as structs (which is usually the right native Perl data structure to use for that, even though it is not perfect). What strict.pm stops you from doing is making the assumptions that these anonymous things have concrete names in your main namespace - names which you might accidentally use to have one of them override another. (This would be bad.)

Re: Re: Re: Re: Re: Dynamically allocating variables
by Fastolfe (Vicar) on Dec 02, 2001 at 08:55 UTC
    And I guess I just don't understand your question. Do you have Perl constructs in your input that you're trying to place into a hash? Something like this might work in that situation:
    my %data; while (<DATA>) { my ($key, $value) = eval $_ or die; $data{$key} = $value; } print $data{other_key}->[1]; # data __DATA__ some_key => { data => 'structure', number => 1 } other_key => [ qw/ other data structure / ] third_key => "and a simple third"
    Is this what you're getting at? If not, I need to see something more specific.