in reply to Perl for loop
#!/usr/bin/perl use strict; use warnings; use feature qw{ say }; my @student = qw( John Jane Jack Jules Jim ); my @age = ( 20, 19, 21, 22, 18 ); my $whose_birthday = 'Jane'; for (my $i = 0; $i <= $#student; $i++) { # ~~ if ($student[$i] eq $whose_birthday) { $age[$i]++; say "Happy birthday $student[$i], you're now $age[$i]!" } }
Update: Hash is a better data structure for such a task, though.
#!/usr/bin/perl use strict; use warnings; use feature qw{ say }; my %age_of = (John => 20, Jane => 19, Jack => 21, Jules => 22, Jim => 18); my $whose_birthday = 'Jane'; $age_of{$whose_birthday}++; say "Happy birthday $whose_birthday, you're now $age_of{$whose_birthda +y}!";
($q=q:Sq=~/;[c](.)(.)/;chr(-||-|5+lengthSq)`"S|oS2"`map{chr |+ord }map{substrSq`S_+|`|}3E|-|`7**2-3:)=~y+S|`+$1,++print+eval$q,q,a,
|
|---|