On Thu Jan 08 2009 @ 11:56, Taylor, Andrew (ASPIRE) wrote: > # In a number of places, I have code that looks like the following. > > > > my $default_type; > > > > if( $split_line[0] eq "DEFAULT_INPUT" ) > > { > > $default_type = "INPUT"; > > } <snip> > This works OK, but I'm trying to avoid declaring variables seperately > from assigning them (wherever possible), and trying to keep the size of > the script down without losing human legibility.
You can use the statement modifier conditional form, in which case, the if follows the assignment. Many people find this easier to read for such a simple test: my $default_type = "INPUT" if $split_line[0] eq "DEFAULT_INPUT"; See here for more: http://perldoc.perl.org/perlsyn.html#Statement-Modifiers Hope this helps, T -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/