prel doubt

R

rajesh

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
 
B

Brian Wakem

rajesh said:
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.
 
J

Jürgen Exner

rajesh said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,537
Members
45,022
Latest member
MaybelleMa

Latest Threads

Top