another perl newbie

guys i know its too simple to ask but the thing is i don' know what to look for in the resources ..

what i wanted to do wuz
suppose i have this variable

$temp = "my name is somethin";

i want to convert the spaces or a particular charecter to something else .. say

$temp = "my+name+is+somethin";Try this:
---
#!/usr/bin/perl
#replace string program by m0dulus
use warnings;

$sentence = "This forum is great\n";
print "before:$sentence";
$sentence =~s/\s//g;
print "after:$sentence";
---

That is, of course, if you have ActivePerl. It should output:
-
This forum is great
Thisforumisgreat
-

The key expression was: $sentence =~s/\s//g;

I used the substitute operator to search for a space, and replace it with nothing, and the /g was a global modifier, to make it search and replace the whole string. Hope this helps.thanks modulus ..it works fine...no problem :)
 
Top