Ask a Question related to PERL Beginners, Design and Development.
-
perl@swanmail.com #1
behavior of semicolon on return line
Does the semicolon behave any differently for a return test statement?
Example,
sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }
or
sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }
thanks
-----------------------------------------
eMail solutions by
[url]http://www.swanmail.com[/url]
perl@swanmail.com Guest
-
Return Line Number of text in a textfield?
Can the line numbers of the text containing a special character be retrieved? e.g. text in a textfield: #line 1 line 2 line 3 #line 4 line... -
What does a semicolon do at the beginning of a line?
Was browsing the documentation on reading a configuration file and found this. What does a semicolon do at the beginning of a line? ; <?php DO... -
Atatch behavior to a specific line in a text member? Possible?
Hi all, I am in need. I have a Search field. When I type in the Search field and submit it, I want the results (from a database) to be placed in an... -
Return second line after a pattern match?
Ritchie wrote: is this what you want? find the "----------" line and skip it fine the 1st line after it and skip it find the 2nd line after it... -
Line Feed vs Carriage Return
"Lynn" <noemail@yahoo.com> wrote in message news:011901c34717$b9a7d5f0$a601280a@phx.gbl... char(10) is the line delimiter on Unix. char(13) +... -
Tim Johnson #2
RE: behavior of semicolon on return line
I don't know, does it?
-----Original Message-----
From: [email]perl@swanmail.com[/email] [mailto:perl@swanmail.com]
Sent: Friday, October 10, 2003 7:02 PM
To: [email]beginners@perl.org[/email]
Subject: behavior of semicolon on return line
Does the semicolon behave any differently for a return test statement?
Example,
sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }
or
sub validate
{ return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }
thanks
-----------------------------------------
eMail solutions by
[url]http://www.swanmail.com[/url]
--
To unsubscribe, e-mail: [email]beginners-unsubscribe@perl.org[/email]
For additional commands, e-mail: [email]beginners-help@perl.org[/email]
Tim Johnson Guest
-
John W. Krahn #3
Re: behavior of semicolon on return line
[email]perl@swanmail.com[/email] wrote:
>
> Does the semicolon behave any differently for a return test statement?
>
> Example,
>
> sub validate
> { return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }
>
> or
>
> sub validate
> { return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }
Trailing commas and semicolons are optional.
( 1, 2, 3, 4 ) is the same as ( 1, 2, 3, 4, ) and { statement1;
statement1; statement1 } is the same as { statement1; statement1;
statement1; }
John
--
use Perl;
program
fulfillment
John W. Krahn Guest
-
Rob Dixon #4
Re: behavior of semicolon on return line
John W. Krahn wrote:
Yes. A the semicolon is a statement separator in Perl. Unlike C,> [email]perl@swanmail.com[/email] wrote:>> >
> > Does the semicolon behave any differently for a return test statement?
> >
> > Example,
> >
> > sub validate
> > { return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/ }
> >
> > or
> >
> > sub validate
> > { return shift =~ /^[a-zA-Z0-9][\w-]*\.[a-zA-z]+$/; }
>
> Trailing commas and semicolons are optional.
>
> ( 1, 2, 3, 4 ) is the same as ( 1, 2, 3, 4, ) and { statement1;
> statement1; statement1 } is the same as { statement1; statement1;
> statement1; }
where it is a statement terminator and the final semicolon is
required. Null statements are also allowed, so
( return 99; }
is the same as
{ return 99 }
or
{ return 99; ; ; ; ; ; ; }
HTH,
Rob
Rob Dixon Guest
-
Jenda Krynicky #5
Re: behavior of semicolon on return line
From: "Rob Dixon" <rob@dixon.port995.com>
As you can see if you ask Perl to show you how did it parse the code:> Yes. A the semicolon is a statement separator in Perl. Unlike C,
> where it is a statement terminator and the final semicolon is
> required. Null statements are also allowed, so
>
> ( return 99; }
>
> is the same as
>
> { return 99 }
>
> or
>
> { return 99; ; ; ; ; ; ; }
perl -MO=Deparse -e "sub foo {return 99}"
perl -MO=Deparse -e "sub foo {return 99;}"
perl -MO=Deparse -e "sub foo {return 99;;;;;;;}"
See
perldoc B::Deparse
Jenda
===== [email]Jenda@Krynicky.cz[/email] === [url]http://Jenda.Krynicky.cz[/url] =====
When it comes to wine, women and song, wizards are allowed
to get drunk and croon as much as they like.
-- Terry Pratchett in Sourcery
Jenda Krynicky Guest



Reply With Quote

