in reply to Flag variables

In addition to the locality issue (where is $flag set vs. where it's eventually tested), it's also not idiomatic Perl. Assuming you *were* going to use a flag variable, it's nice to use Perl's notion of truth:

my $foundFoo =0; foreach my $var( @somearray) { if ($var eq 'foo') { $foundFoo =1; last; } } if ( $foundFoo ) { someaction(); }

And let me also repeat the warning that &action(); does not mean the same as action();; prepending the ampersand, among other things, passes the current value of the @_ array as arguments to action. See perlsub for more information about stuff like that. update a comment by PodMaster alerted me to something here that may be misleading: &foo; is not the same as &foo();, in that the second will not pass @_ to foo, but the two forms still have different semantics; &foo() will call a user-defined sub over a builtin one (with an empty list of arguments), whereas foo() will not.


If not P, what? Q maybe?
"Sidney Morgenbesser"