[ 22769]
Subject: [perl #29073] Reference to incorrect method in documentation of
From: "bob@starlabs.net (via RT)" <perlbug-followup@perl.org>
Message-ID: <rt-3.0.8-29073-85903.18.
1381766820328@perl.org>
Date: 22 Apr 2004 10:49:22 -0000
[ 22829]
perlrun.pod minor fixes :
- the parameter to -x is optional
- pod nit
[ 22837]
Subject: Proposed doc patch for getsockopt
From: perl5-porters@ton.iguana.be (Ton Hospel)
Date: Sun, 16 May 2004 13:35:20 +0000 (UTC)
Message-Id: <c87qmo$u9b$1@post.home.lunix>
[ 22853]
Subject: [PATCH doc] Re: undef loses it magicness when assigned to a variable?
From: Stas Bekman <stas@stason.org>
Date: Thu, 27 May 2004 11:25:08 -0700
Message-ID: <
40B63284.5040203@stason.org>
p4raw-link: @22853 on //depot/perl:
9adebda4fef8cbc5965f9327c10fca15b814f305
p4raw-link: @22837 on //depot/perl:
636e6b1fa3938b0a8cbbecb0b9e8624bbe995355
p4raw-link: @22829 on //depot/perl:
136e4fd6ec637207d88e6a730d1dc2f630367cae
p4raw-link: @22769 on //depot/perl:
cf18bebb9cb15326fe052635ecc0c2e2752b23e6
p4raw-id: //depot/maint-5.8/perl@22864
p4raw-integrated: from //depot/perl@22863 'copy in'
lib/Text/ParseWords.pm (@16727..) 'merge in' sv.h (@22548..)
pod/perlguts.pod (@22756..) pod/perlfunc.pod (@22801..)
pod/perlrun.pod (@22810..) pod/perlapi.pod (@22819..)
returns all of the tokens in a single long list, while &nested_quotewords()
returns a list of token lists corresponding to the elements of @lines.
&parse_line() does tokenizing on a single string. The &*quotewords()
-functions simply call &parse_lines(), so if you're only splitting
-one line you can call &parse_lines() directly and save a function
+functions simply call &parse_line(), so if you're only splitting
+one line you can call &parse_line() directly and save a function
call.
The $keep argument is a boolean flag. If true, then the tokens are
=item SvOK
-Returns a boolean indicating whether the value is an SV.
+Returns a boolean indicating whether the value is an SV. It also tells
+whether the value is defined or not.
bool SvOK(SV* sv)
=item getsockopt SOCKET,LEVEL,OPTNAME
-Returns the socket option requested, or undef if there is an error.
+Queries the option named OPTNAME associated with SOCKET at a given LEVEL.
+Options may exist at multiple protocol levels depending on the socket
+type, but at least the uppermost socket level SOL_SOCKET (defined in the
+C<Socket> module) will exist. To query options at another level the
+protocol number of the appropriate protocol controlling the option
+should be supplied. For example, to indicate that an option is to be
+interpreted by the TCP protocol, LEVEL should be set to the protocol
+number of TCP, which you can get using getprotobyname.
+
+The call returns a packed string representing the requested socket option,
+or C<undef> if there is an error (the error reason will be in $!). What
+exactly is in the packed string depends in the LEVEL and OPTNAME, consult
+your system documentation for details. A very common case however is that
+the option is an integer, in which case the result will be an packed
+integer which you can decode using unpack with the C<i> (or C<I>) format.
+
+An example testing if Nagle's algorithm is turned on on a socket:
+
+ use Socket;
+
+ defined(my $tcp = getprotobyname("tcp"))
+ or die "Could not determine the protocol number for tcp";
+ # my $tcp = Socket::IPPROTO_TCP; # Alternative
+ my $packed = getsockopt($socket, $tcp, Socket::TCP_NODELAY)
+ or die "Could not query TCP_NODELAY SOCKEt option: $!";
+ my $nodelay = unpack("I", $packed);
+ print "Nagle's algorithm is turned ", $nodelay ? "off\n" : "on\n";
+
=item glob EXPR
SvOK(SV*)
The scalar C<undef> value is stored in an SV instance called C<PL_sv_undef>.
-Its address can be used whenever an C<SV*> is needed.
-However, you have to be careful when using C<&PL_sv_undef> as a value in AVs
-or HVs (see L<AVs, HVs and undefined values>).
+
+Its address can be used whenever an C<SV*> is needed. Make sure that
+you don't try to compare a random sv with C<&PL_sv_undef>. For example
+when interfacing Perl code, it'll work correctly for:
+
+ foo(undef);
+
+But won't work when called as:
+
+ $x = undef;
+ foo($x);
+
+So to repeat always use SvOK() to check whether an sv is defined.
+
+Also you have to be careful when using C<&PL_sv_undef> as a value in
+AVs or HVs (see L<AVs, HVs and undefined values>).
There are also the two values C<PL_sv_yes> and C<PL_sv_no>, which contain
boolean TRUE and FALSE values, respectively. Like C<PL_sv_undef>, their
Disables all warnings regardless of C<use warnings> or C<$^W>.
See L<perllexwarn>.
+=item B<-x>
+
=item B<-x> I<directory>
tells Perl that the program is embedded in a larger chunk of unrelated
=item :raw
-A pseudolayer that manipulates other layers. Applying the <:raw>
+A pseudolayer that manipulates other layers. Applying the C<:raw>
layer is equivalent to calling C<binmode($fh)>. It makes the stream
pass each byte as-is without any translation. In particular CRLF
translation, and/or :utf8 intuited from locale are disabled.
Unsets the NV/IV status of an SV.
=for apidoc Am|bool|SvOK|SV* sv
-Returns a boolean indicating whether the value is an SV.
+Returns a boolean indicating whether the value is an SV. It also tells
+whether the value is defined or not.
=for apidoc Am|bool|SvIOKp|SV* sv
Returns a boolean indicating whether the SV contains an integer. Checks