How do I change this to “idiomatic” Perl?

前端 未结 6 2236
名媛妹妹
名媛妹妹 2021-02-09 03:46

I am beginning to delve deeper into Perl, but am having trouble writing \"Perl-ly\" code instead of writing C in Perl. How can I change the following code to use more Perl idiom

6条回答
  •  甜味超标
    2021-02-09 04:08

    One simple change is to use for loops like this:

    for my $i (0 .. $num_of_rows){
        # Do stuff.
    }
    

    For more info, see the Perl documentation on foreach loops and the range operator.

提交回复
热议问题