Click to See Complete Forum and Search --> : @array to string in perl


Sam
09-23-2003, 04:31 PM
I've got an array named @event which was contrived by splitting a scalar string
ex:

@event=split('<br><br>',"Line1<br><br>Line 2<br><br>Line 3");
#@event[0]=Line1
#@event[1]=Line 2
#@event[2]=Line 3

I then change @event[1] to something else, "Line 4" for example. How would I reverse that split, making the final string "Line1<br><br>Line 4<br><br>Line 3"?
I'm sure this is pretty simple, but help is much appreciated

Jeff Mott
09-23-2003, 05:20 PM
my $string = join('<br><br>', @event);

Sam
09-23-2003, 05:58 PM
excellent, one more question, say @event was a 13 element array, and I wanted every element but @event[3] into that string (I don't need @event again, so if it gets destroyed I'm not too worried...

Jeff Mott
09-23-2003, 08:26 PM
You can remove that element withsplice(@event, 3, 1);Note also that when you reference a single element of an array you are really referencing a scalar. So @event[3] should be written $event[3].