Saboo, Nandakishore wrote:
> Hi,

Hello,

> As Tom Phoenix said there are many ways to do it, this is one of the way we 
> can do it.
> 
> +++++++++++++++
> $string = 
> "one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|";
> $added = "abc|";
> 
> @tmp_array = split(/\|/,$string,4);
> 
> for ($i=0;$i<$#tmp_array;$i++)
> {
>         $tmp .= $tmp_array[$i]."|";
> }
> 
> $tmp .= $added ;
> $tmp .= $tmp_array[$#tmp_array] ;
> print $tmp,"\n";

It would be easier to use splice:

$string =
'one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|';
$added = 'abc';

@tmp_array = split /\|/, $string, 4;
splice @tmp_array, 3, 0, $added;

print join '|', @tmp_array;




John
-- 
use Perl;
program
fulfillment

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to