cvs commit: perlfaq perlfaq.pod perlfaq4.pod perlfaq7.pod perlfaq8.pod

[email protected]
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     02/11/10 09:35:47

  Modified:    .        perlfaq.pod perlfaq4.pod perlfaq7.pod perlfaq8.pod
  Log:
  + perlfaq7: How can I catch accesses to undefined variables/functions/
  methods?
  	* Brian McCauley suggested that this answer use warnings instead of
  	black magic
  
  + perlfaq8: Why doesn't open() return an error when a pipe open fails?
  	* minor corrections for consistent style
  
  + perlfaq4: How can I access/change the first N letters of a string?
  	* changed the title (updated perlfaq.pod too)
  	   + get rid of the /
  	   + expand the answer to include changes to any part of
  	   the string
  	   + talk about characters, not just letters
  
  	* the answer now shows the fourth argument to substr()
  
  	* the $first_byte variable is now the $first_char variable
  	because it isn't necessarily a byte.
  
  Revision  Changes    Path
  1.13      +3 -3      perlfaq/perlfaq.pod
  
  Index: perlfaq.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq.pod,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -w -r1.12 -r1.13
  --- perlfaq.pod	5 Sep 2002 00:48:40 -0000	1.12
  +++ perlfaq.pod	10 Nov 2002 17:35:47 -0000	1.13
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq - frequently asked questions about Perl ($Date: 2002/09/05 00:48:40 $)
  +perlfaq - frequently asked questions about Perl ($Date: 2002/11/10 17:35:47 $)
   
   =head1 DESCRIPTION
   
  @@ -405,7 +405,7 @@
   
   =item *
   
  -How can I access/change the first N letters of a string?
  +How can I access or change N characters of a string?
   
   =item *
   
  @@ -961,7 +961,7 @@
   
   =item *
   
  -How can I catch accesses to undefined variables/functions/methods?
  +How can I catch accesses to undefined variables, functions, or methods?
   
   =item *
   
  
  
  
  1.36      +14 -12    perlfaq/perlfaq4.pod
  
  Index: perlfaq4.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
  retrieving revision 1.35
  retrieving revision 1.36
  diff -u -w -r1.35 -r1.36
  --- perlfaq4.pod	30 Oct 2002 18:40:34 -0000	1.35
  +++ perlfaq4.pod	10 Nov 2002 17:35:47 -0000	1.36
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq4 - Data Manipulation ($Revision: 1.35 $, $Date: 2002/10/30 18:40:34 $)
  +perlfaq4 - Data Manipulation ($Revision: 1.36 $, $Date: 2002/11/10 17:35:47 $)
   
   =head1 DESCRIPTION
   
  @@ -650,22 +650,24 @@
   See the documentation for Text::Autoformat to appreciate its many
   capabilities.
   
  -=head2 How can I access/change the first N letters of a string?
  +=head2 How can I access or change N characters of a string?
   
  -There are many ways.  If you just want to grab a copy, use
  -substr():
  +You can access the first characters of a string with substr().
  +To get the first character, for example, start at position 0
  +and grab the string of length 1.  
   
  -    $first_byte = substr($a, 0, 1);
   
  -If you want to modify part of a string, the simplest way is often to
  -use substr() as an lvalue:
  +	$string = "Just another Perl Hacker";
  +    $first_char = substr( $string, 0, 1 );  #  'J'
   
  -    substr($a, 0, 3) = "Tom";
  +To change part of a string, you can use the optional fourth
  +argument which is the replacement string.
   
  -Although those with a pattern matching kind of thought process will
  -likely prefer
  +    substr( $string, 13, 4, "Perl 5.8.0" );
   
  -    $a =~ s/^.../Tom/;
  +You can also use substr() as an lvalue.
  +
  +    substr( $string, 13, 4 ) =  "Perl 5.8.0";
   
   =head2 How do I change the Nth occurrence of something?
   
  
  
  
  1.11      +4 -19     perlfaq/perlfaq7.pod
  
  Index: perlfaq7.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq7.pod,v
  retrieving revision 1.10
  retrieving revision 1.11
  diff -u -w -r1.10 -r1.11
  --- perlfaq7.pod	4 Sep 2002 22:33:45 -0000	1.10
  +++ perlfaq7.pod	10 Nov 2002 17:35:47 -0000	1.11
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq7 - General Perl Language Issues ($Revision: 1.10 $, $Date: 2002/09/04 22:33:45 $)
  +perlfaq7 - General Perl Language Issues ($Revision: 1.11 $, $Date: 2002/11/10 17:35:47 $)
   
   =head1 DESCRIPTION
   
  @@ -675,31 +675,16 @@
           print "No such command: $string\n";
       } 
   
  -=head2 How can I catch accesses to undefined variables/functions/methods?
  +=head2 How can I catch accesses to undefined variables, functions, or methods?
   
   The AUTOLOAD method, discussed in L<perlsub/"Autoloading"> and
   L<perltoot/"AUTOLOAD: Proxy Methods">, lets you capture calls to
   undefined functions and methods.
   
   When it comes to undefined variables that would trigger a warning
  -under C<-w>, you can use a handler to trap the pseudo-signal
  -C<__WARN__> like this:
  +under C<use warnings>, you can promote the warning to an error.
   
  -    $SIG{__WARN__} = sub {
  -
  -	for ( $_[0] ) {		# voici un switch statement 
  -
  -	    /Use of uninitialized value/  && do {
  -		# promote warning to a fatal
  -		die $_;
  -	    };
  -
  -	    # other warning cases to catch could go here;
  -
  -	    warn $_;
  -	}
  -
  -    };
  +	use warnings FATAL => qw(uninitialized);
   
   =head2 Why can't a method included in this same file be found?
   
  
  
  
  1.14      +4 -4      perlfaq/perlfaq8.pod
  
  Index: perlfaq8.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq8.pod,v
  retrieving revision 1.13
  retrieving revision 1.14
  diff -u -w -r1.13 -r1.14
  --- perlfaq8.pod	8 Oct 2002 08:06:40 -0000	1.13
  +++ perlfaq8.pod	10 Nov 2002 17:35:47 -0000	1.14
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq8 - System Interaction ($Revision: 1.13 $, $Date: 2002/10/08 08:06:40 $)
  +perlfaq8 - System Interaction ($Revision: 1.14 $, $Date: 2002/11/10 17:35:47 $)
   
   =head1 DESCRIPTION
   
  @@ -763,7 +763,7 @@
   
   =head2 Why doesn't open() return an error when a pipe open fails?
   
  -If the second argument to a piped C<open> contains shell
  +If the second argument to a piped open() contains shell
   metacharacters, perl fork()s, then exec()s a shell to decode the
   metacharacters and eventually run the desired program.  If the program
   couldn't be run, it's the shell that gets the message, not Perl. All
  @@ -771,9 +771,9 @@
   successfully started.  You can still capture the shell's STDERR and
   check it for error messages.  See L<"How can I capture STDERR from an
   external command?"> elsewhere in this document, or use the
  -L<IPC::Open3> module.
  +IPC::Open3 module.
   
  -If there are no shell metacharacters in the argument of C<open>, Perl
  +If there are no shell metacharacters in the argument of open(), Perl
   runs the command directly, without using the shell, and can correctly
   report whether the command started.
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.