On Jan 8, 3:56 am, andrew.tayl...@hmrcaspire.com (Andrew Taylor) wrote: > Hello > > I have a script that is (at one point) reading through a file. The file > is processed line by line and each line split into an array like so: > > while (<$TESTFILE>) > > { > > my $cur_line=$_; > > chomp ($cur_line); > while (my $cur_line = <$TESTFILE>) { chomp $cur_line;
> my @split_line = split( /$t_delim/, $cur_line ); > > # 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"; > > } > > if ( $split_line[0] eq "DEFAULT_OUTPUT" ) > > { > > $default_type = "OUTPUT"; > > } > 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. > > Is there a neater/cleverer way of doing this? > my $default_type = $split_line[0] =~ /INPUT/ ? 'INPUT' : 'OUTPUT'; -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/