Mailing List Archive

request for diagnostic: 'break' in Perl5 (fwd)
Larry, I request that a bareword string "break" should
emit a class S warning:

(S) A severe warning (mandatory).

Something like:

break interpreted to mean string not loop exit last()

or some such.



------- start of forwarded message -------
Path: csnews!boulder!bloom-beacon.mit.edu!panix!news.eecs.umich.edu!newshost.marcam.com!news.mathworks.com!newsfeed.internetmci.com!howland.reston.ans.net!vixen.cso.uiuc.edu!news.uoregon.edu!cs.uoregon.edu!cs.uoregon.edu!news
From: chrissch@cs.uoregon.edu (Chris Schleicher)
Newsgroups: comp.lang.perl.misc
Subject: 'break' in Perl5
Date: 13 Sep 1995 17:59:12 -0700
Organization: University of Oregon Computer and Information Sciences Dept.
Lines: 27
Message-ID: <437up0$ljp@suffix.cs.uoregon.edu>
NNTP-Posting-Host: suffix.cs.uoregon.edu

I (perhaps naively) assumed that 'break' was a legal command in Perl, and
that I could use it to drop out of loops (I realize that 'last' will do this).
Could someone please enlighten me on exactly what 'break' does. For
instance, the following script will parse and execute, but the 'break'
seems to simply be ignored:

#!/local/bin/perl5
#
foreach (@ARGV) { break; print "@ARGV\n"; }

% ./test.pl this that the other
this that the other
this that the other
this that the other
this that the other
%

I've glanced through "Programming Perl" as well as the webbified Perl manual.
While there is plenty of info on 'last', I haven't found info on 'break'.

Thanks in advance,

Chris
--
Chris Schleicher email: chrissch@cs.uoregon.edu
URL: http://www.cs.uoregon.edu/~chrissch/
University of Oregon
------- end of forwarded message -------

--
: =09wow
: =09=E0=E9
Gad, I hate MIME.
--Larry Wall in <9509111657.AA04720@scalpel.netlabs.com>
Re: request for diagnostic: 'break' in Perl5 (fwd) [ In reply to ]
: Larry, I request that a bareword string "break" should
: emit a class S warning:
:
: (S) A severe warning (mandatory).
:
: Something like:
:
: break interpreted to mean string not loop exit last()
:
: or some such.

Hmm, with -w it already does:

Unquoted string "break" may clash with future reserved word at test.pl line 3.
Useless use of a constant in void context at test.pl line 3.

But lemme think about it some more. It does seem like a common problem.

Larry