print "Primul program PERL\n"; $var = 23; #numele variabilelor sunt diferite $VAR = 33; $_VAR = 44; $text = "23"; $var2 = undef; #$verificare = defined($text); print "Rezultatul verificarii:\n $verificare"; $adunare = $var + $_VAR; print STDOUT "\nRezultatul adunarii:"; print "\n$adunare\n"; print '\n$adunare'; print "\n"; print "Variabila text contine: $text\n"; # print 'Variabila "$adunare" are valoarea ',"$adunare"; $var = $var +1 ; $var++; print "\n $var"; $VAR = $VAR + 67; print "\n $VAR"; $VAR+=67; print "\n $VAR"; print "-oOo-" x 10; $concatenare = $var . $VAR; print "\n$concatenare"; =pod comentarea mai multor linii de cod =cut $y = 1; # integer $x = 3.14; # floating point $w = 2.75E-6; # scientific/engineering notation $u = 0xffff; # hexadecimal __END__ OPERATORI DE ATRIBUIRE SI OPERATORI MATEMATICI = Assign + Add − Subtract * Multiply ** Exponentiation / Divide % Modulus += Assign add −= Assign subtract *= Assign multiply **= Assign exponentiation /= Assign divide %= Assign modulus ++ Autoincrement −− Autodecrement cos() Cosine sin() Sine sqrt() Square root log() Natural logarithm (base e) pentru transformare se utilizeaza: log(x)baza(y)=ln(x)/ln(y) radical din a = e la puterea ln(a)/2 radical din a = 10 la puterea log10(a)/2 radical de ordinul n din a = a la puterea 1/n OPERATORI LOGICI Perl does not have specific boolean type, but every scalar value, if checked using if will be either true or false. From the documentation perlsyn: The number 0, the strings '0' and '', the empty list "()", and "undef" are all false in a boolean context. All other values are true. Negation of a true value by "!" or "not" returns a special false value. When evaluated as a string it is treated as '', but as a number, it is treated as 0. So the following scalar values are considered false: • undef - the undefined value • 0 the number 0, even if you write it as 000 or 0.0 • '' the empty string. • '0' the string that contains a single 0 digit. All other scalar values, including the following are true: • 1 any non-0 number • ' ' the string with a space in it • '00' two or more 0 characters in a string • "0\n" a 0 followed by a newline • 'true' • 'false' yes, even the string 'false' evaluates to true. LOGICAL operator: and or not xor LOGICAL C-style operator: && || ! BITWISE operator: & | ^ and Called Logical AND operator. If both the operands are true then the condition becomes true. && C-style Logical AND operator. Copies a bit to the result if it exists in both operands. or Called Logical OR Operator. If any of the two operands are non zero then the condition becomes true. || C-style Logical OR operator. Copies a bit if it exists in eather operand. not Called Logical NOT Operator. Use to reverses the logical state of its operand. If a condition is true then Logical NOT operator will make it false. TABELE DE ADEVĂR and or xor not A B | A && B A B | A || B A B | A xor B A | ! 1 1 | 1 1 1 | 1 1 1 | 0 1 | 0 1 0 | 0 1 0 | 1 1 0 | 1 0 | 1 0 1 | 0 0 1 | 1 0 1 | 1 0 0 | 0 0 0 | 0 0 0 | 0 BITWISE OPERATORS (OPERATORI PE BIȚI) $a = 0011 1100 $b = 0000 1101 $a & $b = 0000 1100 $a | $b = 0011 1101 $a ^ $b = 0011 0001 ~ $a = 1100 0011 & Binary AND Operator copies a bit to the result if it exists in both operands. Example: ($a & $b) will give 12 which is 0000 1100 | Binary OR Operator copies a bit if it exists in eather operand. Example: ($a | $b) will give 61 which is 0011 1101 ^ Binary XOR Operator copies the bit if it is set in one operand but not both. Example: ($a ^ $b) will give 49 which is 0011 0001 ~ Binary Ones Complement Operator is unary and has the efect of 'flipping' bits. Example: (~$a ) will give -61 which is 1100 0011 in 2's complement form due to a signed binary number. << Binary Left Shift Operator. The left operands value is moved left by the number of bits specified by the right operand. Example: $a << 2 will give 240 which is 1111 0000 >> Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. Example: $a >> 2 will give 15 which is 0000 1111 MISCELLANEOUS OPERATORS . Binary operator dot . concatenates two strings. x The repetition operator x returns a string consisting of the left operand repeated the number of times specified by the right operand. .. The range operator .. returns a list of values counting (up by ones) from the left value to the right value. -> The arrow operator is mostly used in dereferencing a method or variable from an object or a class name. PRECEDENCE Perl operators have the following associativity and precedence, listed from highest precedence to lowest. left terms and list operators (leftward) left -> nonassoc ++ -- right ** right ! ~ \ and unary + and - left =~ !~ left * / % x left + - . left << >> nonassoc named unary operators nonassoc < > <= >= lt gt le ge nonassoc == != <=> eq ne cmp left & left | ^ left && left || nonassoc .. ... right ?: right = += -= *= etc. left , => nonassoc list operators (rightward) right not left and left or xor https://perldoc.perl.org/perlop https://www.tutorialspoint.com/perl/perl_operators.htm