On Fri, 5 Jul 2002, Trey Harris wrote: : Did I hear somewhere that paragraph mode (i.e., C<$/ = ''>) is going away? : I can't find it in my archives, so maybe it was one of my feverish Perl 6 : dreams (of which I've had too many lately, after spending a few days in : training with Damian ;-) but I think I heard it said by someone with : authority at some point.
Paragraph mode is not going away--it's merely going elsewhere. :-) : If so, what's the rationale? Another case of "you can't do it right : internationally, so better not to do it at all"? No, it's simply that using a global variable to control something that should be a filehandle attribute is the wrong way to go about it. : I'm just looking at the huge number of stanza-based files and : system-utility output sysadmins deal with every day using C<$/ = ''>, and : thinking "yeah, I could just write a grammar, but it's just a simple regex : match in paragraph mode..." No problem, you'll just say something like: $fh = open $filename, ":para"; for <$fh> -> $para { ... } Eventually the Perl 5 folks will get around to implementing such user-oriented layers in Perl 5, but at the moment they're still working on the encoding-oriented layers, which is fine. Likewise, you won't undefine $/ to slurp a file. You just put in a :slurp layer: $fh = open $filename, ":slurp"; $text = <$fh>; Of course, that's kind of silly. Really, when you want the entire file, you should just use the slurp function: $text = slurp $filename; That's particularly handy on standard input: $text = slurp $*IN; It's kind of klunky to bind a mode to an existing handle: mode $*IN: ":slurp"; $text = <$*IN>; I suppose that slurp with no arguments should slurp from @ARGS. Like Perl 5, it should probably slurp one file per, er, slurp, rather than automatically concatenating all the files. for slurp -> $file { ... } Larry