komm leider wieder nicht weiter :/
aufgabe: write a function that calculates the number of occurrences of "a" in a word (z.b. abbbattaaajqaAAAgtAWG) passed to it, and main program that calls this subroutine.use split
ich hab das:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
$| = 1;
use strict; use warnings;
print "exercise 4\n";
print "please enter a word:";
chomp (my $word = <STDIN>);
my $letter = "g/i";
while (<>) {
chop;
foreach $letter (split) {
if ($letter eq $word) {
print "$_\n";
my $score ++;
}
}
}
print " number of A in word: $score\n"
ich bekomme aber keine ausgabe :/
und bei der 2. aufgabe steh ich total auf dem schlauch.
write an iterative subroutine that computes N factorial. the Programm should ask the use for an integer number N and Output N! the program should return an error message if the entered number is not a positive whole number.
hierbei habe ich keine Ahnung wie ich anfangen soll, geschweige denn wie es weiter aussehen sollte :(
modedit Editiert von GwenDragon: Code formatiert
Last edited: 2015-04-05 09:27:37 +0200 (CEST)