or with multiple statements
------_=_NextPart_001_01CB3D15.16227884
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable
Hi list,
I just implemented multiple statements after 'or' but it wouldn't work =
unless I put the semicolon after the closing bracket. Am I right =
guessing that the trailing semicolon ends the statement at the beginning =
and is therefore invariably needed?
#!/usr/bin/perl -w
use strict;
use warnings;
chown 204, 202, 'test.txt' or do {
warn "FEHLER!\n";
warn "chown nicht möglich: $!\n";
};
chmod 0775, 'test.txt' or do {
warn "FEHLER!\n";
warn "chmod nicht möglich: $!\n";
};
Kind regards,
Nora
------_=_NextPart_001_01CB3D15.16227884--
Re: or with multiple statements
Hi Nora,
On Monday 16 August 2010 10:31:48 HACKER Nora wrote:
> Hi list,
>
> I just implemented multiple statements after 'or' but it wouldn't work
> unless I put the semicolon after the closing bracket. Am I right guessing
> that the trailing semicolon ends the statement at the beginning and is
> therefore invariably needed?
Yes, you're right. An =ABEXPR() or do { ... };=BB statement is a normal sta=
tement,
not a construct like =ABif (! EXPR()) { .... }=BB which does not require a=
trailing semicolon.
>
> #!/usr/bin/perl -w
> use strict;
> use warnings;
>
> chown 204, 202, 'test.txt' or do {
> warn "FEHLER!\n";
> warn "chown nicht möglich: $!\n";
> };
Please consider using if here instead. Also, you should only warn once with=
the complete warning.
Regards,
Shlomi Fish
>
> chmod 0775, 'test.txt' or do {
> warn "FEHLER!\n";
> warn "chmod nicht möglich: $!\n";
> };
>
> Kind regards,
> Nora
=2D-
=2D--------------------------------------------------------- -------
Shlomi Fish http://www.shlomifish.org/
http://www.shlomifish.org/humour/ways_to_do_it.html
God considered inflicting XSLT as the tenth plague of Egypt, but then
decided against it because he thought it would be too evil.
Please reply to list if it's a mailing list post - http://shlom.in/reply .
--
To unsubscribe, e-mail: beginners-unsubscribe [at] perl.org
For additional commands, e-mail: beginners-help [at] perl.org
http://learn.perl.org/