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