[svn:perlfaq] r6572 - perlfaq/trunk
[email protected] Wed, 28 Jun 2006 01:22:49 -0700 (PDT)
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
Author: rafael
Date: Wed Jun 28 01:22:48 2006
New Revision: 6572
Modified:
perlfaq/trunk/perlfaq8.pod
Log:
Fix the indentation of some code examples in perlfaq8
Modified: perlfaq/trunk/perlfaq8.pod
==============================================================================
--- perlfaq/trunk/perlfaq8.pod (original)
+++ perlfaq/trunk/perlfaq8.pod Wed Jun 28 01:22:48 2006
@@ -392,14 +392,13 @@
it exits.
unless ($pid = fork) {
- unless (fork) {
- exec "what you really wanna do";
- die "exec failed!";
- }
- exit 0;
- }
- waitpid($pid,0);
-
+ unless (fork) {
+ exec "what you really wanna do";
+ die "exec failed!";
+ }
+ exit 0;
+ }
+ waitpid($pid, 0);
See L<perlipc/"Signals"> for other examples of code to do this.
Zombies are not an issue with C<system("prog &")>.
@@ -517,7 +516,7 @@
managed to finish its output without filling up the disk:
END {
- close(STDOUT) || die "stdout close failed: $!";
+ close(STDOUT) || die "stdout close failed: $!";
}
The END block isn't called when untrapped signals kill the program,
@@ -831,13 +830,13 @@
my @ok = ();
if (open(GREP, "-|")) {
- while (<GREP>) {
+ while (<GREP>) {
chomp;
- push(@ok, $_);
- }
- close GREP;
+ push(@ok, $_);
+ }
+ close GREP;
} else {
- exec 'grep', @opts, $search_string, @filenames;
+ exec 'grep', @opts, $search_string, @filenames;
}
Just as with system(), no shell escapes happen when you exec() a list.
@@ -900,15 +899,15 @@
the initial telnet handshaking, then the standard dual-process
approach will suffice:
- use IO::Socket; # new in 5.004
+ use IO::Socket; # new in 5.004
$handle = IO::Socket::INET->new('www.perl.com:80')
- || die "can't connect to port 80 on www.perl.com: $!";
+ or die "can't connect to port 80 on www.perl.com: $!";
$handle->autoflush(1);
- if (fork()) { # XXX: undef means failure
- select($handle);
- print while <STDIN>; # everything from stdin to socket
+ if (fork()) { # XXX: undef means failure
+ select($handle);
+ print while <STDIN>; # everything from stdin to socket
} else {
- print while <$handle>; # everything from socket to stdout
+ print while <$handle>; # everything from socket to stdout
}
close $handle;
exit;