in reply to Difficulty handling std{in,out,err} of child processes
my %used; for ( @{ $graph_data->{Edges} } ) { $edges{$_->{in}->[0]} //= {}; $edges{$_->{in}->[0]}->{$_->{in}->[1]} //= []; push( @{ $edges{$_->{in}->[0]}->{$_->{in}->[1]} }, $_->{out} ); $used{$_->{out}} //= 0; $used{$_->{out}}++; if ( grep { $used{$_} > 1 } keys( %used ) ) { die( 'Only one input per node!' ); } }
Perl has a thing called autovivification, which means that that could be simplified to:
my %used; for ( @{ $graph_data->{Edges} } ) { push @{ $edges{ $_->{in}[0] }{ $_->{in}[1] } }, $_->{out}; if ( ++$used{ $_->{out} } > 1 ) { die 'Only one input per node!'; } }
eval { ... }; if ( $! ) { say "Error starting ID $_->{id}: $!"; }
The $! variable does nothing useful there. You need to use the $@ variable instead.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Difficulty handling std{in,out,err} of child processes
by eternaleye (Novice) on Dec 01, 2010 at 07:16 UTC | |
by jwkrahn (Abbot) on Dec 01, 2010 at 07:27 UTC | |
by eternaleye (Novice) on Dec 01, 2010 at 07:37 UTC | |
by eternaleye (Novice) on Dec 01, 2010 at 07:19 UTC |