cvs commit: perlfaq perlfaq4.pod

[email protected]
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     02/07/17 10:46:17

  Modified:    .        perlfaq4.pod
  Log:
  * How do I expand function calls in a string?
  
  removed the example that tries to use scalar context in ().
  it just doesn't work
  
  Revision  Changes    Path
  1.26      +6 -9      perlfaq/perlfaq4.pod
  
  Index: perlfaq4.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
  retrieving revision 1.25
  retrieving revision 1.26
  diff -u -w -r1.25 -r1.26
  --- perlfaq4.pod	30 May 2002 07:04:25 -0000	1.25
  +++ perlfaq4.pod	17 Jul 2002 17:46:17 -0000	1.26
  @@ -1,6 +1,6 @@
   =head1 NAME
   
  -perlfaq4 - Data Manipulation ($Revision: 1.25 $, $Date: 2002/05/30 07:04:25 $)
  +perlfaq4 - Data Manipulation ($Revision: 1.26 $, $Date: 2002/07/17 17:46:17 $)
   
   =head1 DESCRIPTION
   
  @@ -557,14 +557,6 @@
   
       print "My sub returned @{[mysub(1,2,3)]} that time.\n";
   
  -If you prefer scalar context, similar chicanery is also useful for
  -arbitrary expressions:
  -
  -    print "That yields ${\($n + 5)} widgets\n";
  -
  -Version 5.004 of Perl had a bug that gave list context to the
  -expression in C<${...}>, but this is fixed in version 5.005.
  -
   See also ``How can I expand variables in text strings?'' in this
   section of the FAQ.
   
  @@ -1398,6 +1390,11 @@
   	$_ **= 3;
   	$_ *= (4/3) * 3.14159;  # this will be constant folded
       }
  +    
  +which can also be done with map() which is made to transform
  +one list into another:
  +
  +	@volumes = map {$_ ** 3 * (4/3) * 3.14159} @radii;
   
   If you want to do the same thing to modify the values of the
   hash, you can use the C<values> function.  As of Perl 5.6
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.