Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Message from discussion The map function

Path: g2news1.google.com!news4.google.com!out02a.usenetserver.com!news.usenetserver.com!in04.usenetserver.com!news.usenetserver.com!nx01.iad01.newshosting.com!newshosting.com!novia!border2.nntp.dca.giganews.com!nntp.giganews.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!trndny09.POSTED!9c7fbf25!not-for-mail
From: Jürgen Exner <jurge...@hotmail.com>
Newsgroups: comp.lang.perl.misc
Subject: Re: The map function
Message-ID: <0mpv04lchbf7lm0b9a9rh5mafikbop6qqf@4ax.com>
References: <slrng0mhgh.ujm.tadmc@tadmc30.sbcglobal.net> <1208755083_3027@news.newsgroups.com> <x7fxtfeojz.fsf@mail.sysarch.com> <1208828437_3041@news.newsgroups.com> <4cqq045hepcr8jj6llnrfk8pr7r9rume5i@4ax.com> <x78wz6tscj.fsf@mail.sysarch.com> <1208839744_3044@news.newsgroups.com> <slrng0r3ie.j1a.allergic-to-spam@no-spam-allowed.org> <1208899188_3070@news.newsgroups.com> <slrng0t2vg.sbv.allergic-to-spam@no-spam-allowed.org> <1208998517_3083@news.newsgroups.com>
X-Newsreader: Forte Agent 4.2/32.1118
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Lines: 45
Date: Thu, 24 Apr 2008 02:09:51 GMT
NNTP-Posting-Host: 71.112.10.152
X-Complaints-To: abuse@verizon.net
X-Trace: trndny09 1209002991 71.112.10.152 (Wed, 23 Apr 2008 22:09:51 EDT)
NNTP-Posting-Date: Wed, 23 Apr 2008 22:09:51 EDT

"Gerry Ford" <ge...@nowhere.ford> wrote:
[...]
>my $pat; eval ('$pat = qr/$_/') or do {prompt $@; next};
[...]

>I'm still confused on the whole }; thing.  

There is no }; thing. Understanding this is your problem.

There are 'blocks' that are enclosed in curly braces {.....}. Period.

And then there are statements. Individual statements are separated by a
; in Perl, i.e. between any two statements you have to write a ;.

In your original progam you had [reformatted to make it more obvious]
    open(FILE, "<$killrc") and 
	do {SomeVeryLongWhatever} print @filter;

What you meant was 
    open(FILE, "<$killrc") and 
	do {SomeVeryLongWhatever};
    print @filter;

If you want print() to be a new statement, then you have to place a
semicolon between the preceeding statement and the print(). If you don't
then you will get that syntax error because perl had to assume that you
are continuing the preceeding statement. After all, it could have been
that you wanted to add 5 to the result of do, something like 

	do {SomeVeryLongWhatever} + 5;

which is perfectly legal. The only way for perl to know that a new
statement is starting is if you put that semicolon there.
 
>With this version, I've eliminated the the do{}; 

No, you haven't. See the one line of code I quoted above.

> If I put a semicolon after the foreach close curly 
>brace, I get no change in behavior in the program. ??

That's just a surplus empty statement. Perl doesn't care if you create a
dozen  or a million.

jue