- Scalar variables always start with a $ sign, name is alphanumeric (a-zA-Z0-9) and underscore (_)
- A scalar variable can hold either a string or a number
- Value assignment to varaible is done by the = sign
- Use the my keyword to declare variables (optional but recommended)
$this_is_a_long_scalar_variable $ThisIsAlsoGoodButWeUseItLessInPerl $h $H # $h and $H are two different variables
#!/usr/bin/perl use strict; use warnings; my $greeting = "Hello world\n"; my $the_answer = 42; print $greeting; print $the_answer, "\n"; $the_answer = "Hi, you two";
A scalar can hold either string or numerical value. They can be changed any time. If a value was not given it holds the special value undef.