develooper Front page | perl.perl5.porters | Postings from May 2003

perldata.pod corrections

Thread Next
Shlomi Fish
May 14, 2003 01:08
perldata.pod corrections
Message ID:
--- orig/perldata.pod	Mon May 12 17:51:14 2003
+++ pod/perldata.pod	Wed May 14 11:03:00 2003
@@ -7,10 +7,14 @@
 =head2 Variable names
 Perl has three built-in data types: scalars, arrays of scalars, and
-associative arrays of scalars, known as "hashes".  Normal arrays
-are ordered lists of scalars indexed by number, starting with 0 and with
-negative subscripts counting from the end.  Hashes are unordered
-collections of scalar values indexed by their associated string key.
+associative arrays of scalars, known as "hashes".  A scalar is a 
+single string (of any size, limited only by the available memory),
+number, or reference to something (which will be further discussed
+in L<perlref>).  Normal arrays are ordered lists of scalars indexed
+by number, starting with 0. When a negative subscript is supplied
+to an array, it retrieves that index from the end of the array.
+Hashes are unordered collections of scalar values indexed by
+their associated string key.
 Values are usually referred to by name, or through a named reference.
 The first character of the name tells you to what sort of data
@@ -187,10 +191,11 @@
 To find out whether a given string is a valid non-zero number, it's
 sometimes enough to test it against both numeric 0 and also lexical
-"0" (although this will cause B<-w> noises).  That's because strings
-that aren't numbers count as 0, just as they do in B<awk>:
+"0" (although this will cause noises if extra warnings were turned on
+in the interpreter).  That's because strings that aren't numbers count 
+as 0, just as they do in B<awk>:
-    if ($str == 0 && $str ne "0")  {
+    if (($str == 0) && ($str ne "0"))  {
 	warn "That doesn't look like a number";
@@ -312,6 +317,8 @@
     $Price = '$100';	# not interpreted
     print "The price is $Price.\n";	# interpreted
+As you see, there is no double interpolation in Perl.
 As in some shells, you can enclose the variable name in braces to
 disambiguate it from following alphanumerics (and underscores).
 You must also do
@@ -335,6 +342,8 @@
 anything more complicated in the subscript will be interpreted as
 an expression.
+=head3 Version Strings
 A literal of the form C<v1.20.300.4000> is parsed as a string composed
 of characters with the specified ordinals.  This form, known as
 v-strings, provides an alternative, more readable way to construct
@@ -354,6 +363,8 @@
 Note that using the v-strings for IPv4 addresses is not portable unless
 you also use the inet_aton()/inet_ntoa() routines of the Socket package.
+=head3 Meta Literals
 The special literals __FILE__, __LINE__, and __PACKAGE__
 represent the current filename, line number, and package name at that
 point in your program.  They may be used only as separate tokens; they
@@ -381,6 +392,8 @@
 as it is seen (during compilation), at which point the corresponding
 __DATA__ (or __END__) token has not yet been seen.
+=head3 Barewords
 A word that has no other interpretation in the grammar will
 be treated as if it were a quoted string.  These are known as
 "barewords".  As with filehandles and labels, a bareword that consists
@@ -397,10 +410,12 @@
 end of the enclosing block.  An inner block may countermand this
 by saying C<no strict 'subs'>.
+=head3 Array Joining Delimiter
 Arrays and slices are interpolated into double-quoted strings
 by joining the elements with the delimiter specified in the C<$">
-variable (C<$LIST_SEPARATOR> in English), space by default.  The
-following are equivalent:
+variable (C<$LIST_SEPARATOR> if the "use English;" pragma is
+specified), space by default.  The following are equivalent:
     $temp = join($", @ARGV);
     system "echo $temp";

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About