Hello Uri,
 Thanks for the input. comments are below: 

> since @triggers must be the same length as @commands then use that fact:
> 
>       my @triggers = ('0') x @triggers ;

that's a good idea -- that I actually recently used. in this case I left
the list explicit b/c the triggers will not necessarily be always all of
the same value.

> i can't imagine ever doing a for loop on a flag. use flow control ops
> (last/next/redo)
> 

That won't cut it here -- I want to finish up the current row ( the
inner ), and then terminate ( the outer ). last will only let me stop
now.

> then you loop over that in normal perl fashion:
> 
>       for my $cmd_data ( @commands ) {
> 

eh. I must admit I was too lazy to remind myself of enough Perl to do a
structure at that time, but I am gladly doing it now :D


> i don't like the look of that. it isn't bad code but not my style. just
> think about the failure mode of the shell commands you are running. they
> may print nothing to stdout but something to stderr. that or die may
> catch it but it would be better to test $? and see what the process
> itself exited with. also some commands may return some error text in
> stdout. i would do it this way:
> 
>       my $result = `$cmd` ;
>       $? == 0 or die "could not execute command [$cmd]\n" ;
> 

This is a good idea, and in some cases I can also see adding another
field to the structure - to trigger a hlat on certain exit codes.

>       if( $result == $trig ) {
> 
>               print ON_RED, $result, RESET, "\t" ;
>               last ;
>       }
>       else {
>               print $result, "\t" ;
>       }
> 

I went with a variant of this one as it seems the most elegant option
when having to retain setting the flag to terminate the outer loop. too
bad there isn't a last-outer-when-done-inner kind of thing :D

> that should be enough to keep you busy! :)

I'd say! Thanks for the advice, hopefully writing some perl every month
will keep my taste standards high and I will stop forgetting everything
about it every four months:D

 -Federico



_________________________________________
-- "'Problem' is a bleak word for challenge" - Richard Fish
(Federico L. Lucifredi) - http://www.lucifredi.com



 
_______________________________________________
Boston-pm mailing list
[email protected]
http://mail.pm.org/mailman/listinfo/boston-pm

Reply via email to