On Thu, Jul 29, 1999 at 12:14:59PM -0400, John Porter wrote: > Earlier I wrote: > > > > Kevin Reid wrote: > > > Something to try shortening: > > > > > > @ARGV='iMax:Documents:Info:lwall-quotes.txt';$/='%% > > > ';@l=<>;$_=$l[rand@l];chomp;print > > > > Two characters: > > > > @ARGV='iMax:Documents:Info:lwall-quotes.txt';$/='%% > > ';@l=<>;print$l[rand@l]=~/(.*)/ > > To which Ronald J Kimball responded by saying that the > semantics of /(.*)/ is different because $/ has been > changed. Actually, I meant the semantics of the whole block of code, not of the regular expression. Sorry about the confusion. > I was not able to confirm that assertion; my tests > showed /(.*)/ still considers . (dot) to exclude \n > specifically, not $/. Can anyone shed some light on > this? Is it a perl version difference? > That's my point. Unlike the original, your code only accounts for newlines, and it only prints the first line of the selected block, without a trailing newline. The original code prints all the lines of the selected block, with a trailing newline. Try these two code blocks, where I have replaced reading from a file with reading from DATA. $/='%% ';@l=<DATA>;$_=$l[rand@l];chomp;print __END__ This is the first block. It is one line. %% This is the second block. It is two lines. Here is the second line. %% $/='%% ';@l=<DATA>;print$l[rand@l]=~/(.*)/ __END__ This is the first block. It is one line. %% This is the second block. It is two lines. Here is the second line. %% ==== Want to unsubscribe from Fun With Perl? Well, if you insist... ==== Send email to <fwp-request@technofile.org> with message _body_ ==== unsubscribe