my $bool = not (1==1);
if ($bool eq "") {
print "False stringifies to the empty string.\n"
} else { print "Nope.\n" }
####
my $bignum = 1000;
for (1..1000) { $bignum *= $bignum }
print "bignum is now $bignum\n";
my $epsilon = 1/$bignum;
print "epsilon is now $epsilon\n";
####
my $foo = 3;
my $x = print($foo) + 7;
# There we used print (which is a list operator) as
# a function; it returns true, which in numeric
# context is 1. $x is now 8
print "\n";
sub mult { # Declare a function...
print "Entering function bar\n 1";
# Here print is used as a statement.
my $product = 1;
for (@_) {
$product *= $_;
print " * $_" }
print " = $product\nExiting function bar\n";
return $product;
}
print mult 42, $x;
# Here print is used as a statement,
# but mult (a function) is used as a list operator.
print "\n";
####
print join "\n",
split(/\s+/,"Just Another Perl Hacker"),
"\n";
####
int main()
{
char buf[50];
char a[] = {'a', 'b', 'c'};
sprintf (buf, "Hello %s here\n", a);
printf ("%s", buf);
}
####
my $count = @{[@foo, @bar, @baz]};
print "There are $count elements altogether between the three arrays.\n";
####
$;=sub{$/};@;=map{my($a,$b)=($_,$;);$;=sub{$a.$b->()}}
split//,".rekcah lreP rehtona tsuJ";$\=$ ;->();print$/