cvs commit: perlfaq perlfaq4.pod

[email protected] (brian d foy) 27 Apr 2005 00:18:04 -0000
Newsgroups perl.cvs.perlfaq
Message-ID <[email protected]>
cvsuser     05/04/26 17:18:04

  Modified:    .        perlfaq4.pod
  Log:
  * fixed variable name issue (the match needs to operate on the right variable
  
  Revision  Changes    Path
  1.64      +12 -12    perlfaq/perlfaq4.pod
  
  Index: perlfaq4.pod
  ===================================================================
  RCS file: /cvs/public/perlfaq/perlfaq4.pod,v
  retrieving revision 1.63
  retrieving revision 1.64
  diff -u -r1.63 -r1.64
  --- perlfaq4.pod	22 Apr 2005 18:52:38 -0000	1.63
  +++ perlfaq4.pod	27 Apr 2005 00:18:04 -0000	1.64
  @@ -1351,9 +1351,9 @@
   same thing.  Once you find the element, you stop the loop with last.
   
   	my $found;
  -	foreach my $element ( @array )
  +	foreach ( @array )
   		{
  -		if( /Perl/ ) { $found = $element; last }
  +		if( /Perl/ ) { $found = $_; last }
   		}
   
   If you want the array index, you can iterate through the indices
  @@ -1361,15 +1361,15 @@
   that satisfies the condition.
   
   	my( $found, $index ) = ( undef, -1 );
  -    for( $i = 0; $i < @array; $i++ )
  -    	{
  -        if( $array[$i] =~ /Perl/ )
  -        	{
  -        	$found = $array[$i];
  -        	$index = $i;
  -        	last;
  -        	}
  -        }
  +	for( $i = 0; $i < @array; $i++ )
  +		{
  +		if( $array[$i] =~ /Perl/ )
  +			{
  +			$found = $array[$i];
  +			$index = $i;
  +			last;
  +			}
  +		}
   
   =head2 How do I handle linked lists?