behavior of semicolon on return line

Ask a Question related to PERL Beginners, Design and Development.

  1. #1

    Default 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

  2. Similar Questions and Discussions

    1. 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...
    2. 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...
    3. 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...
    4. 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...
    5. 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) +...
  3. #2

    Default 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

  4. #3

    Default 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

  5. #4

    Default Re: behavior of semicolon on return line

    John W. Krahn wrote:
    > [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; }
    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; ; ; ; ; ; ; }

    HTH,

    Rob


    Rob Dixon Guest

  6. #5

    Default Re: behavior of semicolon on return line

    From: "Rob Dixon" <rob@dixon.port995.com>
    > 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; ; ; ; ; ; ; }
    As you can see if you ask Perl to show you how did it parse the code:

    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

Posting Permissions

  • You may not post new threads
  • You may post replies
  • You may not post attachments
  • You may not edit your posts

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139