# Inserting short strings into longer strings -- strncpy in Perl? - PERL Beginners

Edward Wijaya wrote:  perldoc -f substr -- Gunnar Hjalmarsson Email: http://www.gunnar.cc/cgi-bin/contact.pl...

1. ## Re: Inserting short strings into longer strings -- strncpy in Perl?

Edward Wijaya wrote:

perldoc -f substr

--
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Guest

2. ## Re: Inserting short strings into longer strings -- strncpy in Perl?

and

perldoc -f rand

--
Email: http://www.gunnar.cc/cgi-bin/contact.pl
Gunnar Guest

3. ## Re: Inserting short strings into longer strings -- strncpy in Perl?

On Sep 3, Edward Wijaya said:

position \$pos.

\$a = "perl";
\$b = "t ea";
substr(\$a, 2, 0, \$b);
print \$a; # "pet earl"

To get a random position, I'd use:

substr(\$big, rand(length \$big), 0, \$small);

--
Jeff "japhy" Pinyan % How can we ever be the sold short or
RPI Acacia Brother #734 % the cheated, we who for every service
http://japhy.perlmonk.org/ % have long ago been overpaid?
http://www.perlmonks.org/ % -- Meister Eckhart

Jeff Guest

4. ## Inserting short strings into longer strings -- strncpy in Perl?

Hi,

Suppose I have these two arrays:

arr1 = ('GATGGATTAAAGGAGAGGTACTTACAGG',
'CGCCCAAGAGGCCAGAGCGGAGCGGGGA',
'CGTTAATGCATTAATTTTAGTTAAAACT');

arr2 = ('tcctcta',
'aggccac',
'agctgcg');

Is there any efficient way to copy each element
of arr2 as part of each elements in arr1
such that it gives result:

arr3 = ('GAtcctctaAAGGAGAGGTACTTACAGG',
'CGCCCAAGAGGCCAGaggccacCGGGGA',
'CGTTAAagctgcgATTTTAGTTAAAACT');

#the starting position to be copied to in arr1 can is random.

Regards,
Edward WIJAYA
SINGAPORE
Edward Guest

5. ## RE: Inserting short strings into longer strings -- strncpy in Perl?

From: Jeff 'japhy' Pinyan <mailto:org> wrote:

: On Sep 3, Edward Wijaya said:
:
: : arr1 = ('GATGGATTAAAGGAGAGGTACTTACAGG',
: : 'CGCCCAAGAGGCCAGAGCGGAGCGGGGA',
: : 'CGTTAATGCATTAATTTTAGTTAAAACT');
: :
: : arr2 = ('tcctcta',
: : 'aggccac',
: : 'agctgcg');
: :
: :
: : Is there any efficient way to copy each element
: : of arr2 as part of each elements in arr1
: : such that it gives result:
: :
: : arr3 = ('GAtcctctaAAGGAGAGGTACTTACAGG',
: : 'CGCCCAAGAGGCCAGaggccacCGGGGA',
: : 'CGTTAAagctgcgATTTTAGTTAAAACT');
:
: \$str at position \$pos.
:
: \$a = "perl";
: \$b = "t ea";
: substr(\$a, 2, 0, \$b);
: print \$a; # "pet earl"
:
: To get a random position, I'd use:
:
: substr(\$big, rand(length \$big), 0, \$small);

array3 indicates the string was to overwrite at a
random position. I assume the entire string must be inside
the result.

my \$start = length( \$big ) - length( \$small ) + 1;

substr( \$big, rand \$start, length \$small ) = \$small;

HTH,

Charles K. Clarkson
--
Mobile Homes Specialist
254 968-8328

Charles Guest

6. ## Problems installing DBD-Interbase on Fedora

Hi, everybody!

I have to work with FireBird database, for a project of mine.

I grabbed from CPAN a DBD-InterBase (version 0.43) to work with, and
installed it on Windows. It works perfectly.

I also installed it on Red Hat 9 at my work place and it works very well.
The problems started when I tried to install DBD-Interbase on Fedora, at my
client's place.

I get the same error no matter what version of DBD-Interbase I use.

When I type "make" I get the following error:

"Error: Cannot p function definition from 'strEQ(item, #name)) { \' in
Interbase.xs, line 478 ' in Interbase.xs, line 487n definition from'
keyname = #name;
make: *** [InterBase.c] Error 1"

Can anyone tell me where is the problem or what does this error message
mean?

Or what can I do, to make it work?

Any help is highly appreciated.
Cristi Ocolisan.

Cristi Guest

7. ## Re: Problems installing DBD-Interbase on Fedora

On Fri, 3 Sep 2004, Cristi Ocolisan wrote:

This sounds like a possible problem with the module itself, but I don't
know anything about Interbase, so I'm not sure where to start.

You may have better luck by trying either the DBI list, or if you get no
help there, contact the module authors directly.

Information on the DBI users list is available here:

<http://lists.perl.org/showlist.cgi?name=dbi-users>
<http://www.mail-archive.com/org/>

According to CPAN.org, DBD::Interbase was written by Edwin Pratomo
<org> and Daniel Ritz <ch>:

<http://search.cpan.org/~edpratomo/DBD-InterBase-0.43/InterBase.pm>

It may also be worth contacting these two for suggestions.

Or maybe someone here will speak up, but I think in this case you'll
have more luck by going to the module specific list for advice...

--
Chris Devers com
http://devers.homeip.net:8080/blog/

np: 'The Greatest Phone Message of All Time'
by Jonathan Goldstein
from 'This American Life: Crimebusters and Crossed Wires'
Chris Guest

8. ## RE: Problems installing DBD-Interbase on Fedora

Hi Chris,

I already asked on perl.dbi.users this question and I got only one response.
It seems that I have to ask the authors directly.

Anyway, I found a different driver, called Bundle::DBD::InterBase that works
also on Fedora.

Thank you.

-----Original Message-----
From: Chris Devers [mailto:com]
Sent: 3 septembrie 2004 17:26
To: Cristi Ocolisan
Cc: org
Subject: Re: Problems installing DBD-Interbase on Fedora

On Fri, 3 Sep 2004, Cristi Ocolisan wrote:

This sounds like a possible problem with the module itself, but I don't
know anything about Interbase, so I'm not sure where to start.

You may have better luck by trying either the DBI list, or if you get no
help there, contact the module authors directly.

Information on the DBI users list is available here:

<http://lists.perl.org/showlist.cgi?name=dbi-users>
<http://www.mail-archive.com/org/>

According to CPAN.org, DBD::Interbase was written by Edwin Pratomo
<org> and Daniel Ritz <ch>:

<http://search.cpan.org/~edpratomo/DBD-InterBase-0.43/InterBase.pm>

It may also be worth contacting these two for suggestions.

Or maybe someone here will speak up, but I think in this case you'll
have more luck by going to the module specific list for advice...

--
Chris Devers com
http://devers.homeip.net:8080/blog/

np: 'The Greatest Phone Message of All Time'
by Jonathan Goldstein
from 'This American Life: Crimebusters and Crossed Wires'

Cristi Guest

9. ## Re: Inserting short strings into longer strings -- strncpy in Perl?

Yes, you are right Charles.
And thanks so much too for Gunnar and Jeff.

Best,
Edward WIJAYA
SINGAPORE
Edward Guest

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•