@a=(1,2,3,4,5,6,7,8,9,10,11,12,13); print grep {$_<10 && $_>5;} @a; |
@a=(1,2,3,4,5,6,7,8,9,10,11,12,13); foreach (@a){ print $_ if ($_<10 && $_>5); } |
opendir(DIR,"testdir"); my @dateien = readdir(DIR); closedir(DIR); my @htm= grep (/\.htm$/,@dateien); print join(" ",@htm); |
@a=(1,2,3,4,5,6,7,8,9,10,11,12,13,7,3,4,5,1,2,8,5,4,11,1234,5,0,9,0,9,8,7,5); $anzahl= grep {$_==5;} @a; print "Die 5 ist $anzahl mal enthalten"; |
@a=(1,2,3,4,5,6,7,8,9,10,11,12,13,1,2); print grep {$temp{$_}==2} grep{$temp{$_}++} @a; |
use strict; open (my $IN,"<datei.txt") || die "can not open datei: $!"; print grep /Sommer|Sonne/i, <$IN>; close $IN; |
open (my $IN,'<datei.txt') || die "Error: $!"; while (<$IN>){ print $_ if ($_=~ /Sommer|Sonne/i); } close $IN; |