in reply to Distinct field name output attempt
Untested, but you get the idea. Note that localising $, inside the foreach isn't a very smart idea for performance issues, you'd better localising it slightly outside the loop if you want to gain some CPU cycles.foreach $field (param) { # Isolate non-empty values my @values = grep { ! /^\s*$/ } param($field); next unless @values; # Skip if nothing available # Establish a header line. Note that I added an "Other" class my $header = "Other:"; $header = "First:" if $field =~ /Data_One/; $header = "Second:" if $field eq /Second_Part/; # Print it all. $, is the output record separator for prints local $, = "\n"; print $header, @values, "\n"; }
Moreover, if you're only interested into these two selection boxes, you'd better iterate over them directly:
foreach $field (qw(Data_One Second_Part)) { # Isolate non-empty values my @values = grep { ! /^\s*$/ } param($field); next unless @values; # Skip if nothing available # Establish a header line. my $header = "First:"; $header = "Second:" if $field =~ /Second_Part/; # Print it all. $, is the output record separator for prints local $, = "\n"; print $header, @values, "\n"; }
Flavio (perl -e 'print(scalar(reverse("\nti.xittelop\@oivalf")))')
Don't fool yourself.
|
|---|