Posted by: Sourav | April 26, 2014

Substitute a character with another in a string in Perl


$DNA=”ABCFEFGHIKLOMNOPQRSTTTTTTT”;
#print “$DNA\n”;
$RNA=$DNA;
$RNA=~s/t/U/gi;
print $RNA;

exit;

 

~ is the binding operator,it means apply the operation on the right to the string in the variable on the left.

s is the substitution operator,t is the character to be substituted with u,

g and i are options for s,

g=global which means this operation will on all part of the string

i=case insensitivity

 

 

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Categories

%d bloggers like this: