home | O'Reilly's CD bookshelfs | FreeBSD | Linux | Cisco | Cisco Exam  


Book Home Programming PerlSearch this book

25.10. Style

When it is necessary to have platform-specific code, consider keeping it in one place to ease porting to other platforms. Use the Config module and the special variable $^O to differentiate between platforms.

Be careful in the tests you supply with your module or programs. A module's code may be fully portable, but its tests may well not be. This often happens when tests spawn other processes or call external programs to aid in the testing, or when (as noted above) the tests assume certain things about the filesystem and paths. Be careful not to depend on a specific output style for errors, even when checking $! for "standard" errors after a syscall. Use the Errno module instead.

Remember that good style transcends both time and culture, so for maximum portability, you must seek to understand the universal amidst the exigencies of your existence. The coolest people are not prisoners of the latest cool fad; they don't have to be, because they are not worried about being "in" with respect to their own culture, programmatically or otherwise. Fashion is a variable, but style is a constant.



Library Navigation Links

Copyright © 2002 O'Reilly & Associates. All rights reserved.