1. qw(): The 'quote word' function qw()
is used to generate a list of words.
qw is also used to be delimiter to tell the interpretor where is the begin and end of context follow qw.
my $name=qw(Jake Sharry Eric)
my $name=("Jake", "Sharry", "Eric")
Above statements are the same meaning.
2. List assignment:
($fred, $barney, $dino) = ("flintstone", "rubble", "undef");
Can swap two variables:
($a, $b)=($b, $a);
3. scalar and list context:
$a = something; # scalar context
@b = something; # list context
($c,$d) = something; # list context
($f) = something; # list context
example:
@people=qw(red barney betty);
@sorted=sort @people; # list context: barney, betty, red
$number = 42 + @people;# scalar context: 42 + 3 gives 45
another:
list: @backwards = qw/ yabba dabba doo /; # gives doo,dabba,yabba
scalar: $backwards = qw/ yabba dabba doo /; # gives oodabbadabbay
<STDIN> :
$lines = <STDIN>;
@linet = <STDIN>;