Thanks, Dennis! You pointed me in the right direction. foreach $my_element(@alllegs) { unless ($my_element eq '') {print " $my_element <br> \n";} }
Works like a champ! Jan Cohen ----- Original Message ----- From: "Dennis Stout" [EMAIL PROTECTED] > > I'm just learning perl and would like to know how to print the contents of > > an array, without printing any of the elements in the array that might be > > empty. > > foreach (@days) { > unless =~ // print; > } > > I do believe will do it. > > Dennis Stout > > > > For instance: > > > > I'm parsing info in from a form: > > > > $day2 = $field{'x_Day2'} ; > > $day3 = $field{'x_Day3'} ; > > $day4 = $field{'x_Day4'} ; > > > > and let's say that the form element for x_Day3 was left blank when > > submitted. > > > > Now, I make an array: > > > > @days=("$day2","$day3",$day4"); > > > > I'd like to be able to print the elements of the array that contain > > information ($day2,$day4) without printing out a new line for $day3. I've > > looked at the join and foreach statements, but thus far I've only been able > > to print each element of the array, whether it's got an assigned value or > > not. Hence, the results of my current script look something like this: > > > > Tuesday > > > > Thurdsay > > > > when I'd really like to leave the blank line out between Tuesday and > > Thursday. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]