Re: perlfaq6: I put a regular expression into $/ but it didn't work. What's wrong?

[email protected] (Robert Spier)
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
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.