Re: perlfaq6: I put a regular expression into $/ but it didn't work. What's wrong?
[email protected] (Robert Spier) Sat, 30 Oct 2004 10:17:59 -0700
| Newsgroups | perl.perlfaq.workers,perl.documentation |
|---|---|
| Message-ID | <[email protected]> |
> +
> + use File::Stream;
> + my $stream = File::Stream->new($filehandle);
> +
> + $/ = qr/\s*,\s*/;
> + print "$_\n" while <$stream>;
I know this is the example from the docs, but you end up still putting
a regex in $/, and it won't work for (and will screw up) other
filehandles in the program.
This would be a safer way to show it:
use File::Stream;
my $stream = File::Stream->new($filehandle,
separator => qr/\s*,\s*/,
);
print "$_\n" while <$stream>;
-R