Gossamer Forum
Home : General : Perl Programming :

How would I print this array?

Quote Reply
How would I print this array?
If anyone can help, thanks.

I have an array @country

This array can hold anything from one to four values. i.e.

United Kingdom
Scotland
Wales
Ireland

I am trying to print all the values in the array and have them seperated by ~~ so it would print like this

United Kingdom~~Scotland~~Wales~~Ireland
or
United Kingdom~~Scotland
or just
United Kingdom

depending on whats in the array.

I`ve tried lots of methods, I can get all the values with
$countries = "@country";

but the values are seperated by spaces, I could then regex the $countries but that would also replace the space in United Kingdom which I do not want to do.

Any ideas much appreciated, thanks.

chmod

Last edited by:

chmod: Feb 28, 2002, 7:48 AM
Quote Reply
Re: [chmod] How would I print this array? In reply to
$countries = join '~~', @array;
Quote Reply
Re: [RedRum] How would I print this array? In reply to
Thanks RedRum,

what a beauty, it works just fine.
I didn`t realise the LIST part could be an array.

I`ve been working on the mystery of multiselects and multi-uploads not working together in DBMan and have now cracked it. Ta very much.
chmod

Last edited by:

chmod: Feb 28, 2002, 8:48 AM