in reply to Re: problem with variables
in thread problem with variables

Ok, you aksed for it, @res is the array with hashes and ... represents a very long unique key. What happens here: $row contains a starttime and endtime. What I try to ckeck for is if there are gaps in time between the rows:
foreach $row (@res) { if(defined $merge->{...} ) { if ( $merge->{...}->{next_samp} == $row->{starttime}) { $merge->{...}->{endtime} = $row->{endtime} ; $merge->{...}->{next_samp} = $row->{endtime} + 1./ +$row->{srate} ; } else { delete $merge->{...}->{next_samp} ; $dummy[++$#dummy] = $merge->{...} ; $merge->{ ...} = $row ; $merge->{...}->{next_samp} = $row->{endtime} + 1./ +$row->{srate} ; } } else { $merge->{ ...} = $row ; $merge->{...}->{next_samp} = $row->{endtime} + 1./$row +->{srate} ; } }

Replies are listed 'Best First'.
Re^3: problem with variables
by blazar (Canon) on Oct 19, 2005 at 11:39 UTC
    Well, it seems that in the meanwhile you have solved your problem. My point was about preparing a suitable complete but minimal example still exhibiting the problem. This is a general recommendation as to how to ask for help, and sometimes it's hard or even impossible to do, but that's rare. More commonly it even happens that while doing so one will find the answer to his own question.

    Now, as side notes to comment you code:

    • I wouldn't use all those nested if's; I'd recommend you to read up something about next, last and while you're there also redo,
    • I wouldn't assign to $dummy[++$#dummy], but stick with push, since it's what it's actually for.