prel doubt

Discussion in 'Perl Misc' started by rajesh, Aug 2, 2005.

  1. rajesh

    rajesh Guest

    what is the meaning of


    LINE:

    for(;;){
    statements;
    last LINE if $foo;
    next LINE if /^#/;
    statemetns;
    }

    my doubt is what is this /^#/ represents?

    I will be so thankful for clearing my doubt
    SIva Rajesh
    rajesh, Aug 2, 2005
    #1
    1. Advertising

  2. rajesh

    Brian Wakem Guest

    rajesh wrote:

    > what is the meaning of
    >
    >
    > LINE:
    >
    > for(;;){
    > statements;
    > last LINE if $foo;
    > next LINE if /^#/;
    > statemetns;
    > }
    >
    > my doubt is what is this /^#/ represents?
    >
    > I will be so thankful for clearing my doubt
    > SIva Rajesh



    It skips comments.

    More precisely, if $_ begins with #, the current iteration of the loop is
    ended and the next iteration of the loop begins.


    --
    Brian Wakem
    Email: http://homepage.ntlworld.com/b.wakem/myemail.png
    Brian Wakem, Aug 2, 2005
    #2
    1. Advertising

  3. rajesh wrote:
    > what is the meaning of


    It is a poorly written loop

    > LINE:
    >
    > for(;;){
    > statements;
    > last LINE if $foo;
    > next LINE if /^#/;


    Using last and next as the only loop control is very bad style. I agree they
    come in handy for handling special exceptions, but normally a reader should
    be able to tell the exit condition by looking at the loop control condition.

    > statemetns;
    > }
    >
    > my doubt is what is this /^#/ represents?


    This is a very common Perl idiom. It tries to match $_ against the regular
    expression ^#, i.e. checks if a line begins with the hashmark character (or
    pound sign or Santa Fu or whatever you want to call it).

    For details see
    perldoc perlre
    perldoc perlop, section "Quote and quote-like operators"

    jue
    Jürgen Exner, Aug 2, 2005
    #3
  4. rajesh

    John Bokma Guest

    John Bokma, Aug 2, 2005
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Igbal

    Doubt to go .Net technology

    Igbal, Nov 8, 2003, in forum: ASP .Net
    Replies:
    1
    Views:
    488
    Ed Kaim [MSFT]
    Nov 17, 2003
  2. Bob Nelson

    doubt about doubt

    Bob Nelson, Jul 28, 2006, in forum: C Programming
    Replies:
    11
    Views:
    610
  3. Replies:
    0
    Views:
    546
  4. Peter Otten
    Replies:
    2
    Views:
    105
    Cousin Stanley
    Aug 10, 2013
  5. Terry Reedy
    Replies:
    0
    Views:
    111
    Terry Reedy
    Aug 10, 2013
Loading...

Share This Page