my $x = 1;
my $y;
if ($y = $x) { #NOTE the single = for assignment, 
    # NOT == for testing, the value of the expression is tested 
    # after the assignment
    print "we have set $y to $x, and it is true too\n";
} 

    #GENERALLY we would not suggest using a line like this as it
    # is likely to look like a mistake when read later

    #HOWEVER, extending this idea:

$x = "the quick brown fox";
if ($x =~ s/brown/green/) {
    print "we converted brown to green\nso we now have:\n$x\n";
}
    #this is common is Perl scripts, where making the substitution
    # and testing that it happened in one statement is very powerful
