=head1 NAME
-perlfaq8 - System Interaction ($Revision: 1.36 $, $Date: 1999/01/08 05:36:34 $)
+perlfaq8 - System Interaction ($Revision: 1.39 $, $Date: 1999/05/23 18:37:57 $)
=head1 DESCRIPTION
=head2 How do I find out which operating system I'm running under?
-The $^O variable ($OSNAME if you use English) contains the operating
-system that your perl binary was built for.
+The $^O variable ($OSNAME if you use English) contains an indication of
+the name of the operating system (not its release number) that your perl
+binary was built for.
=head2 How come exec() doesn't return?
=head2 How do I read just one key without waiting for a return key?
Controlling input buffering is a remarkably system-dependent matter.
-If most systems, you can just use the B<stty> command as shown in
+On many systems, you can just use the B<stty> command as shown in
L<perlfunc/getc>, but as you see, that's already getting you into
portability snags.
=head2 How do I clear the screen?
-If you only have to so infrequently, use C<system>:
+If you only have do so infrequently, use C<system>:
system("clear");
}
However, because syscalls restart by default, you'll find that if
-you're in a "slow" call, such as E<lt>FHE<gt>, read(), connect(), or
+you're in a "slow" call, such as <FH>, read(), connect(), or
wait(), that the only way to terminate them is by "longjumping" out;
that is, by raising an exception. See the time-out handler for a
blocking flock() in L<perlipc/"Signals"> or chapter 6 of the Camel.
theory provide (read-only) access to entries in the shadow password
file. To change the file, make a new shadow password file (the format
varies from system to system - see L<passwd(5)> for specifics) and use
-pwd_mkdb(8) to install it (see L<pwd_mkdb(5)> for more details).
+pwd_mkdb(8) to install it (see L<pwd_mkdb(8)> for more details).
=head2 How do I set the time and date?
If you want finer granularity than the 1 second that the sleep()
function provides, the easiest way is to use the select() function as
-documented in L<perlfunc/"select">. If your system has itimers and
-syscall() support, you can check out the old example in
-http://www.perl.com/CPAN/doc/misc/ancient/tutorial/eg/itimers.pl .
+documented in L<perlfunc/"select">. Try the Time::HiRes and
+the BSD::Itimer modules (available from CPAN).
=head2 How can I measure time under a second?
$done = $start = pack($TIMEVAL_T, ());
- syscall( &SYS_gettimeofday, $start, 0) != -1
+ syscall(&SYS_gettimeofday, $start, 0) != -1
or die "gettimeofday: $!";
##########################
Strictly speaking, nothing. Stylistically speaking, it's not a good
way to write maintainable code because backticks have a (potentially
-humungous) return value, and you're ignoring it. It's may also not be very
+humongous) return value, and you're ignoring it. It's may also not be very
efficient, because you have to read in all the lines of output, allocate
memory for them, and then throw it away. Too often people are lulled
to writing:
system("cat /etc/termcap") == 0
or die "cat program failed!";
-Which will get the output quickly (as its generated, instead of only
+Which will get the output quickly (as it is generated, instead of only
at the end) and also check the return value.
system() also provides direct control over whether shell wildcard
}
Just as with system(), no shell escapes happen when you exec() a list.
+Further examples of this can be found in L<perlipc/"Safe Pipe Opens">.
-There are more examples of this L<perlipc/"Safe Pipe Opens">.
+Note that if you're stuck on Microsoft, no solution to this vexing issue
+is even possible. Even if Perl were to emulate fork(), you'd still
+be hosed, because Microsoft gives no argc/argv-style API. Their API
+always reparses from a single string, which is fundamentally wrong,
+but you're not likely to get the Gods of Redmond to acknowledge this
+and fix it for you.
=head2 Why can't my script read from STDIN after I gave it EOF (^D on Unix, ^Z on MS-DOS)?
=back
-=head2 How do I make my program run with sh and csh?
-
-See the F<eg/nih> script (part of the perl source distribution).
+The Proc::Daemon module, available from CPAN, provides a function to
+perform these actions for you.
=head2 How do I find out if I'm running interactively or not?
=head2 How do I timeout a slow event?
Use the alarm() function, probably in conjunction with a signal
-handler, as documented L<perlipc/"Signals"> and chapter 6 of the
+handler, as documented in L<perlipc/"Signals"> and chapter 6 of the
Camel. You may instead use the more flexible Sys::AlarmCall module
available from CPAN.
=head2 How do I use an SQL database?
There are a number of excellent interfaces to SQL databases. See the
-DBD::* modules available from
-http://www.perl.com/CPAN/modules/dbperl/DBD .
+DBD::* modules available from http://www.perl.com/CPAN/modules/DBD .
A lot of information on this can be found at
-http://www.hermetica.com/technologia/perl/DBI/index.html .
+http://www.symbolstone.org/technology/perl/DBI/
=head2 How do I make a system() exit on control-C?
sysopen(FH, "/tmp/somefile", O_WRONLY|O_NDELAY|O_CREAT, 0644)
or die "can't open /tmp/somefile: $!":
-=head2 How do I install a CPAN module?
-The easiest way is to have the CPAN module do it for you. This module
-comes with perl version 5.004 and later. To manually install the CPAN
-module, or any well-behaved CPAN module for that matter, follow these
-steps:
+
+
+=head2 How do I install a module from CPAN?
+
+The easiest way is to have a module also named CPAN do it for you.
+This module comes with perl version 5.004 and later. To manually install
+the CPAN module, or any well-behaved CPAN module for that matter, follow
+these steps:
=over 4
the PERLLIB environment variable
the PERL5LIB environment variable
- the perl -Idir commpand line flag
+ the perl -Idir command line flag
the use lib pragma, as in
use lib "$ENV{HOME}/myown_perllib";
encouraged to use this code in your own programs for fun
or for profit as you see fit. A simple comment in the code giving
credit would be courteous but is not required.
-