next if( $options{"unoccupied"} eq "0" && $_[6] eq "unoccupied\n" ); #### my $dispmode = $options{display} * 2; $dispmode |= $options{coordinate}; # bitwise OR # $dispmode values: 0 == display:0 and coordinate:0 # 1 == display:0 and coordinate:1 # 2 == display:1 and coordinate:0 # 3 == display:1 and coordinate:1 # create a distinct print sub for each mode: # (in the second one, the regex places parens around # the last two comma-delimited fields on the line if # the last field is numeric) my @modesub = ( sub { print $_[0], "
\n" }, sub { ($_=$_[0]) =~ s/([^,]*,-?[\d]+)$/($1)/; print "$_
\n"}, sub { print "" . join("",split /,/, $_[0]) . "\n" }, sub { print "" . join("",split /,/, $_[0], 8) . "\n" } ); for ( @data ) { # the following regex will check if this element of @data has # "unoccupied" following the 6th comma, and nothing thereafter: next if( $options{"unoccupied"} == 0 && /^(?:[^,]*,){6}unoccupied$/ ); $modesub[$dispmode]->( $_ ); } @data = (); # added this to get rid of the data # though maybe that doesn't really matter? print "" if($dispmode & 2); ##
## @data = grep /\S/, ; # skip blank lines chomp @data; # remove newline chars