Perl /
ControlStructures#!/usr/bin/perl # # Kontrol yapıları # <:vspace> use strict; use warnings; <:vspace> my (@d1, @d2, @d3, @d4); my ($x1, $x2, $x3, $x4); <:vspace> # foreach: 1 print "1. foreach: "; @d1 = (1 .. 10); foreach $x1 (@d1) { print "$x1 - "; } print "\n"; <:vspace> <:vspace> # foreach: 2 print "2. foreach: "; @d1 = (11 .. 20); foreach (@d1) { print "$_ - "; } print "\n"; <:vspace> # foreach: 3 print "3. foreach: "; foreach (2 .. 8) { print "$_ - "; } print "\n"; <:vspace> # foreach: 4 print "4. foreach: "; foreach my $letter ('A' .. 'Z') { print "$letter - "; } print "\n"; <:vspace> # foreach: 5 (for gibi davranan foreach) print "5. foreach: "; foreach (my $number = 0; $number < 4; $number++) { print "$number - "; } print "\n"; <:vspace> # foreach: 6 print "6. foreach: "; foreach my $kedi ('Siyam', 'Tekir', 'Van') { print "$kedi - "; } print "\n"; <:vspace> # foreach: 7 print "7. foreach: "; foreach ('Siyam', 'Tekir', 'Van') { print ; } print "\n"; <:vspace> # redo: D�ng� şartını �nemsemeden d�ng�de d�ner. print "redo: "; my $number = 1; while ($number <= 5) { if ( $number <= 10 ) { $number++; redo } } print "$number \n"; <:vspace> # last ile d�ng�n�n sonlandırılması. print "last ile d�ng�n�n sonlandırılması: "; foreach (1 .. 5) { print "$_ -"; last if ($_ == 3); } print "\n"; <:vspace> |