in reply to pointer/alias question

You didn't show us what your expected data looks like, but maybe you should try a different data structure (perldsc):
use strict; use warnings; use Data::Dumper; my %data; my $fsm = 1; my $m = ''; my $i = ''; while(<DATA>) { chomp; if (/^INSTANCE:\s+(\S+)/) { $m = ''; $i = $1; } elsif (/^MODULE:\s+(\S+)/) { $m = $1; $i = ''; } elsif (/^Fsm\s+(\S+)/) { next if !$fsm; if ($m) { $data{'module'}->{$m} = $1; } else { $data{'instance'}->{$i} = $1; } } elsif (/^State\s+(\S+)/) { next if !$fsm; $data{'state'} = $1; } elsif (/^Transition\s+(\S+)/) { next if !$fsm; $data{'transition'} = $1; } } print Dumper(\%data); __DATA__ INSTANCE: i_name Fsm f_name State s_name1 # Transition t_name # State s_name2

Prints:

$VAR1 = { 'instance' => { 'i_name' => 'f_name' }, 'state' => 's_name1' };

Replies are listed 'Best First'.
Re^2: pointer/alias question
by shoness (Friar) on Dec 01, 2010 at 20:35 UTC
    Sorry to çôñfüsè you. I've updated the original node with my expected data...

    In the real dataset, I've got arrays of "states" and "instances" that make the sort of change you propose infeasible. Maybe you meant something else, but I can't flatten it like that. The data would step on itself.