multiple file positioning 
Author Message
 multiple file positioning

 Consider theese two ( pseudo ) loops traversing a file:

 while (<FILE>){
         do  {
               $_=(<FILE>);

             } until etc....

 }

 I'm uncertain about whether the two loops are manipulating the same
 positioner into the file. The desired effect would be that when the
 inner loop exited, the outer loop would resume execution at the same
 position in <FILE> where the inner loop left.  
 Is that what I should achieve ??



Fri, 28 Jun 1996 19:49:56 GMT  
 multiple file positioning
:
:  Consider theese two ( pseudo ) loops traversing a file:
:
:  while (<FILE>){
:          do  {
:                $_=(<FILE>);
:                  
:              } until etc....
:    
:  }
:
:  I'm uncertain about whether the two loops are manipulating the same
:  positioner into the file. The desired effect would be that when the
:  inner loop exited, the outer loop would resume execution at the same
:  position in <FILE> where the inner loop left.  
:  Is that what I should achieve ??

Yes, it works the way you want.  The file position is attached to the
FILE filehandle, not to the syntactic structure.

Interestingly, in Perl 5, I just made m//g work the same way.  The
state of the previous search used to be attached to syntax.  Now it's
attached to the string being searched, so you can use multiple m//g
constructs and have each begin where the previous left off.

Larry



Tue, 02 Jul 1996 01:23:04 GMT  
 multiple file positioning

Quote:

>> Interestingly, in Perl 5, I just made m//g work the same way.  The
>> state of the previous search used to be attached to syntax.  Now it's
>> attached to the string being searched, so you can use multiple m//g
>> constructs and have each begin where the previous left off.

By the way, perl5a4 still have inconsistency in treatment of
$` and $' used in m//g context.

$_ = "aaaaa";
print "\t$`_$&_$'\n" while /a/g;

        _a_aaaa
        _a_aaa
        _a_aa
        _a_a
        _a_

$_ = "aaaaa";
print "\t$`_$&_$'\n" while /(a)/g;

        _a_aaaa
        a_a_aaa
        aa_a_aa
        aaa_a_a
        aaaa_a_

Bare string search set the string after last matched string
in $`, while regexp search set the string from the beginning
of the original string.  I hope this is not an intentional
backward compatibility.

My mg command will run faster when this bug is fixed.

--utashiro



Sun, 07 Jul 1996 10:19:21 GMT  
 multiple file positioning
: By the way, perl5a4 still have inconsistency in treatment of
: $` and $' used in m//g context.
:
: $_ = "aaaaa";
: print "\t$`_$&_$'\n" while /a/g;
:
:       _a_aaaa
:       _a_aaa
:       _a_aa
:       _a_a
:       _a_
:
: $_ = "aaaaa";
: print "\t$`_$&_$'\n" while /(a)/g;
:
:       _a_aaaa
:       a_a_aaa
:       aa_a_aa
:       aaa_a_a
:       aaaa_a_
:
: Bare string search set the string after last matched string
: in $`, while regexp search set the string from the beginning
: of the original string.  I hope this is not an intentional
: backward compatibility.

Nope, it's a bug.  Thanks.

: My mg command will run faster when this bug is fixed.

In that case, your mg command will run faster with Alpha 5.

Larry



Tue, 09 Jul 1996 04:40:08 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. US - TX - DFW - Notes Architects/Developers (Multiple Positions)

2. File position of of every word in a file

3. Multiple edits, multiple files

4. file position in Perl

5. Finding Position in a FILE???

6. File Position

7. Positioning in file?

8. Set current position in a file

9. Maintaining File position.

10. File marker position on partial reads

11. File position, seek function

12. UNIX - Renaming files Multiple Files

 

 
Powered by phpBB® Forum Software