b310 has asked for the wisdom of the Perl Monks concerning the following question:

Hello:

I have a form field named "event". A person submitting the form can select up to five different events.

In my script, I defined my "event" field as an array @event. I want to be able to see all the events a person chose.

The result of this form is sent via email. When I show the results for Event, my script prints all the events in a single row. For example: Monday Night Drills Adults Singles Tournament Adults Doubles Tournament. In this example there are three events, you need to look really closely to see them.

Is there a way that I can manipulate the @event array so when I receive my email I can see the list of events separated by a comma. For example: Monday Night Drills, Adult Singles Tournament, Adult Doubles Tournament.

Or, is there another way that I can manipulate the array so I can easily spot all the events.

Thank you in advance

Replies are listed 'Best First'.
Re: Manipulating Arrays
by tlm (Prior) on Mar 30, 2005 at 18:50 UTC
    my $events_string = join ', ', @events;

    the lowliest monk

      Hi:

      Thank you for your reply. The line of code you gave me works perfectly.

      Thank you again.
Re: Manipulating Arrays
by Zaxo (Archbishop) on Mar 30, 2005 at 18:52 UTC

    Besides join, there is local $, = ', '; invoked by print @event; or, local $" = ', '; which is invoked by $foo = "@event";.

    After Compline,
    Zaxo

Re: Manipulating Arrays
by Fletch (Bishop) on Mar 30, 2005 at 18:46 UTC

    perldoc -f join. Of course possibly overkill, but you might use YAML and let if format things in a readable (if slightly verbose) way.