# Example 1. # @now will be (40, 51, 20, 9, 0, 109, 5, 8, 0) @now = localtime(); # Example 2. # $now will be "Fri Jan 9 20:51:40 2009" $now = localtime(); #### # Example 3. # $sec will be 40, $min will be 51, $hr will be 20 ($sec,$min,$hr) = localtime(); #### my ($x) = localtime(); #### my $x = localtime(); #### print clock(); sub clock { return localtime(); } #### print scalar localtime(); #### my $match_count = ()= /x/g; #### while (<>) { ponder( $_ ); # void context } #### sub print_context { if ( wantarray() ) { print "list\n"; } elsif ( defined wantarray() ) { print "scalar\n"; } else { print "void\n"; } } print_context(); ()= print_context(); scalar print_context(); __END__ void list scalar #### my $beer_inventory = '99 bottles'; print "how much beer? $beer_inventory\n"; $beer_inventory--; # take one down... print "how much beer? $beer_inventory\n"; __END__ how much beer? 99 bottles how much beer? 98 #### my $s = "12 monkeys"; my $n = 31337; my $stringified = ''. $n; # "31337" my $numified = 0+ $s; # 12 my $bool = !! $n; # 1 #### my $scaley = 'snake'; my @listy = $scaley; # does the same thing: #my @listy = ('snake'); #### my @t = ( 'one', 'two' ); my $x = ( 'one', 'two' ); # 'two' my $y = ( 'larry', 'moe', @t ); # 2 my $z = ( 'old', 'man', localtime() ); # "Fri Jan 9 20:51:40 2009" #### my $friend = 'Perl'; my $literal = '$friend'; # literally, '$friend' my $expanded = "$friend"; # literally, 'Perl'