DormanResearch : PerlHints?

Referers: HelpfulHints :: (Remote :: Orphans :: Tree )

Dorman Wiki
Dorman Lab Wiki
Count matches in string: my $cnt = ($str =~ tr/p/p/); # counts the number of times p is found in string
Sum array: my $cnt = 0; ($cnt+=$_) @array;
Count matches in array: my $cnt = scalar( grep {/p/} @array); # counts the number of times p is found in array
Index of maximum array element: my $idx=0; $data[$idx] > $data[$_] or $idx = $_ for 1..$#data;
Environmental Variables: %ENV, for example $ENV{'HOME'}
Hash slice: @hash{@array}
Comments [Hide comments/form]