cvs commit: perlfaq perlfaq6.pod
[email protected] (brian d foy) 3 Nov 2004 22:52:16 -0000
| Newsgroups | perl.cvs.perlfaq |
|---|---|
| Message-ID | <[email protected]> |
cvsuser 04/11/03 14:52:16 Modified: . perlfaq6.pod Log: * I put a regular expression into $/ but it didn't work. What's wrong? updated the reference to FileHandle to use IO::File instead since FileHandle is just a frontend for it. thanks to Uri Guttman for the pointer. :) Revision Changes Path 1.27 +14 -2 perlfaq/perlfaq6.pod Index: perlfaq6.pod =================================================================== RCS file: /cvs/public/perlfaq/perlfaq6.pod,v retrieving revision 1.26 retrieving revision 1.27 diff -u -r1.26 -r1.27 --- perlfaq6.pod 25 Oct 2004 18:47:04 -0000 1.26 +++ perlfaq6.pod 3 Nov 2004 22:52:16 -0000 1.27 @@ -1,6 +1,6 @@ =head1 NAME -perlfaq6 - Regular Expressions ($Revision: 1.26 $, $Date: 2004/10/25 18:47:04 $) +perlfaq6 - Regular Expressions ($Revision: 1.27 $, $Date: 2004/11/03 22:52:16 $) =head1 DESCRIPTION @@ -151,7 +151,19 @@ but don't get your hopes up. Until then, you can use these examples if you really need to do this. -Use the four argument form of sysread to continually add to +If you have File::Stream, this is easy. + + use File::Stream; + my $stream = File::Stream->new( + $filehandle, + separator => qr/\s*,\s*/, + ); + + print "$_\n" while <$stream>; + +If you don't have File::Stream, you have to do a little more work. + +You can use the four argument form of sysread to continually add to a buffer. After you add to the buffer, you check if you have a complete line (using your regular expression).