Code | What it does |
---|---|
#!/usr/bin/perl | shebang |
chomp ($text = <STDIN>); | Insert text without a “nextline” |
print (“Hallo Welt!”); | Text output |
$variable = “inhalt”; | Add a variable |
print $variable; | Variable output |
\n | Nextline |
@array; | Add array |
print $array[0]; | Output of array position 0 |
push ($array, “newValue”); | Add to the end of the array |
unshift … | Add to the beginning |
pop … | Remove at the end |
shift … | Remove at the beginning |
foreach $arrayelement (@array) { print $arrayelement; } | Output of all arrayelements |
if ($nr2 < 1000) { print "nr 2 is smaller than 1000"; } else { print "nr 2 is bigger than 1000"; } | Example if-else |
while ($count != $result) { print $count; print "\n"; $count++; } | While - until |
Discussion
really basic, thanks