in reply to Re^2: CPAN automated tests for IPC
in thread CPAN automated tests for IPC
This is a pretty literal translation of your C file, that should perform exactly the same way (barring typos):
#! perl -slw use strict; use constant { COMP_FILE => "list_comp.txt", COMP_TYPES_FILE => "list_comp_types.txt", }; while( 1 ) { printf "svrmgr> "; chomp( my $command = <STDIN> ); if( $command eq COMP_FILE ) { open my $in, '<', COMP_FILE or printf("Error reading %s\n", COMP_FILE ) and next; print while <$in>; } elsif( $command eq COMP_TYPES_FILE ) { open my $in, '<', COMP_TYPES_FILE or printf("Error reading %s\n", COMP_TYPES_FILE ) and next; print while <$in>; } else if( $command eq 'EXIT' ) { print "Disconnecting...\n"; last; } else { print "Invalid command\n"; } } exit 0;
Easier to maintain?
(Also, just an aside. Are the blank lines in your C code an artifact of posting, or your preferred style?)
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: CPAN automated tests for IPC
by glasswalk3r (Friar) on Mar 17, 2012 at 17:31 UTC |