my $x; # one statement
$x = $y if {condition;} # two statement
####
my $x if ...
presuming
my $x = $y if {condition;}
####
sunorccws04 ~$ cat tpl ; ./tpl
#!/usr/bin/perl
sub showme;
foreach $y ( 1..10) {
$foo = $y;
print showme(), "is the x value\n";
}
sub showme {
my $x;
$x = $y if ($foo %2); # might as well mix up some T/F
}
1 is the x value
0 is the x value
3 is the x value
0 is the x value
5 is the x value
0 is the x value
7 is the x value
0 is the x value
9 is the x value
0 is the x value
####
sunorccws04 ~$ cat tpl ; ./tpl
#!/usr/bin/perl
use strict;
my ($foo, $y);
sub showme;
foreach $y ( 1..10) {
$foo = $y;
print showme(), " is the x value\n";
}
sub showme {
my $x;
$x = $y if ($foo %2); # might as well mix up some T/F
}
is the x value
0 is the x value
is the x value
0 is the x value
is the x value
0 is the x value
is the x value
0 is the x value
is the x value
0 is the x value