Re: cool tricks for inserting element into array?

2005-07-21 Thread Tom Allison
Bryan R Harris wrote: As a sidenote, are questions like this appropriate for the list? I really don't *need* help with this, I was just hoping to expand my personal toolbox with a better way to do something. Every time John, Wiggins, Luke, Bob, Jeff, etc. respond to my emails I know I'm going

Re: cool tricks for inserting element into array?

2005-07-21 Thread John W. Krahn
Tom Allison wrote: John W. Krahn wrote: for ( my $i = @tmp; --$i; ) { splice @tmp, $i, 0, '|'; } How does this fare for large arrays? According to my tests it does poorly on large arrays. John -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail:

RE: cool tricks for inserting element into array?

2005-07-20 Thread Moon, John
Subject: cool tricks for inserting element into array? I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. As a sidenote, are questions like this

RE: cool tricks for inserting element into array?

2005-07-20 Thread Moon, John
Subject: RE: cool tricks for inserting element into array? Subject: cool tricks for inserting element into array? I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string

Re: cool tricks for inserting element into array?

2005-07-20 Thread Jeff 'japhy' Pinyan
On Jul 20, Bryan R Harris said: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. It would also break if elements of @tmp had spaces in them. Well, here's

RE: cool tricks for inserting element into array?

2005-07-20 Thread Bob Showalter
Bryan R Harris wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. I'll bet that's pretty efficient. The problem would come if

Re: cool tricks for inserting element into array?

2005-07-20 Thread Bryan R Harris
Neat, thanks! - Bryan On Jul 20, Bryan R Harris said: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. It would also break if elements of @tmp

Re: cool tricks for inserting element into array?

2005-07-20 Thread John W. Krahn
Bryan R Harris wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. I can think of two ways to do it: splice @tmp, $_, 0, '|'

Re: cool tricks for inserting element into array?

2005-07-20 Thread John W. Krahn
John W. Krahn wrote: Bryan R Harris wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. I can think of two ways to do it: splice @tmp,

Re: cool tricks for inserting element into array?

2005-07-20 Thread John W. Krahn
John W. Krahn wrote: Bryan R Harris wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. I can think of two ways to do it: splice @tmp,

Re: cool tricks for inserting element into array?

2005-07-20 Thread Jay Savage
On 7/20/05, Bryan R Harris [EMAIL PROTECTED] wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. I would do something like:

Re: cool tricks for inserting element into array?

2005-07-20 Thread John W. Krahn
Jay Savage wrote: On 7/20/05, Bryan R Harris [EMAIL PROTECTED] wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. I would do something

Re: cool tricks for inserting element into array?

2005-07-20 Thread John W. Krahn
John W. Krahn wrote: John W. Krahn wrote: Bryan R Harris wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. I can think of two ways to do it:

Re: cool tricks for inserting element into array?

2005-07-20 Thread John W. Krahn
John W. Krahn wrote: Bryan R Harris wrote: I'd like to turn array @tmp from: (1,2,3) to (1,|,2,|,3) I'm using: @tmp = split(' ', join( | , @tmp)); ... but it seems like a waste to create a string and then split it back up again. FYI, I ran a benchmark on the different algorithms