princepawn has asked for the wisdom of the Perl Monks concerning the following question:
if (ref($op_tree->[0]) eq 'ARRAY') {
It just occurred to me that some people might be thinking this would help me with my interview. But it won't the interview is over and I am just trying to improve my skills.
use strict; sub proc; sub proc { my $op_tree = shift; if (ref($op_tree->[0]) eq 'ARRAY') { $op_tree->[0] = proc $op_tree->[0] ; } if (ref($op_tree->[2]) eq 'ARRAY') { $op_tree->[2] = proc $op_tree->[2] ; } my $expr = sprintf '%d %s %d', @$op_tree; warn "EXPR $expr"; eval $expr; } my $sched1 = [ 1, '||', 0 ]; my $sched2 = [ 1, '&&', 0 ]; my $sched3 = [ $sched1, '&&', 1 ]; my $sched4 = [ $sched1, '&&', $sched2 ]; warn proc $sched1; warn proc $sched2; warn proc $sched3; warn proc $sched4;
Edit Masem 2001-11-13 - Small code fix
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: optimizing a binary expression processor (revised)
by chip (Curate) on Nov 14, 2001 at 02:11 UTC | |
by tilly (Archbishop) on Nov 14, 2001 at 16:38 UTC | |
by chip (Curate) on Nov 17, 2001 at 03:29 UTC | |
|
(tye)Re: optimizing a binary expression processor
by tye (Sage) on Nov 14, 2001 at 02:22 UTC |