Perl while statement has the same grammar as C language while statement

Perl while statements have the same grammar as C language while statements. Let's compare the while statement in Perl with the while statement in C language.

Perl while statement

Perl while statement.

# Perl while statement
my $i = 0;
while ($i <10) {
  
  # process
  
  $i ++;
}

C while statement

It is a while statement in C language.

// C language while statement (C99 compatible)
int32_t i = 0;
while (i <10) {
  // process
  
  i ++;
}

Comparison of Perl while statement and C language while statement

Let's compare the comparison between Perl's while statement and C language while statement. The grammar is the same, such as how to use "()" and "{}". In the sample, the declaration of the loop variable is declared and the loop variable is incremented at the end of the while statement.

If you learn repetition with a while statement in C language, you can use the grammar and concept as it is with Perl

If you learn repetition with a while statement in C language, you can use the grammar and concept as it is in Perl. You can use the knowledge you learned in C language as it is in Perl.

Perl takes the syntax of the while statement in C as it is.

Perl is a programming language with dynamic types, but it is similar to the grammar of the while statement in C, except that it is dynamically typed.

Perl is designed so that users who have learned the Unix / Linux environment and C language can use the concepts learned there as they are, so the learning cost is low and programming can be done using the same concepts.

One of the nice features of Perl is that it aimed for affinity and cooperation from the beginning without overly criticizing the C language.

Other similarities between Perl and C

In this article, I wrote that Perl while statements are similar to C while statements, but Perl if statements, for statements, increments / decrements, operator types and priorities, scopes, and reference concepts. Is similar to the C language grammar.

Associated Information