how to replace string

 
Post new topic   Reply to topic    Aprelium Forum Index -> Perl
View previous topic :: View next topic  
Author Message
littlestar
-


Joined: 23 Aug 2005
Posts: 7

PostPosted: Mon Oct 10, 2005 11:50 am    Post subject: how to replace string Reply with quote

I have a query. for example: "SELECT * FROM project". and it executed successful. I replaced " " with "+" as follows:

Code:

my $string = 'SELECT * FROM project';
$string =~ s/ /+/g;


It's OK. result is "SELECT+*+FROM+project".
But when I replace in the opposite, from "+" to " ". It's impossible.

Code:

my $string = 'SELECT+*+FROM+project';
$string =~ s/+/ /g;


So, I changed by this:

Code:

$string =~ tr/+/ /;


Ok. It returned as initial "SELECT * FROM project". But this time, it can't execute SQL query. It has error:
Code:

Insecure dependency in parameter 1 of DBI::db=HASH(0x889e6d8)->prepare method call while running with -T switch at Test/DB.pm line 60.


I don't understand why. please help me
I'm awaiting your reply, thanks so much
Back to top View user's profile Send private message
Anonymoose
-


Joined: 09 Sep 2003
Posts: 2192

PostPosted: Mon Oct 10, 2005 1:17 pm    Post subject: Reply with quote

Use \s to represent a single whitespace character. Not sure whether this will also solve your error, but it should sort your regex out...
_________________

"Invent an idiot proof webserver and they'll invent a better idiot..."
Back to top View user's profile Send private message
aprelium
-


Joined: 22 Mar 2002
Posts: 6800

PostPosted: Mon Oct 10, 2005 2:39 pm    Post subject: Re: how to replace string Reply with quote

littlestar wrote:

Code:

Insecure dependency in parameter 1 of DBI::db=HASH(0x889e6d8)->prepare method call while running with -T switch at Test/DB.pm line 60.

This error is generated because you're using the Perl Tainted mode. Your code is OK, but Perl detected it can be unsecure and allow external unvalidated input to be used without any prior checks.
Please read http://www.aprelium.com/forum/viewtopic.php?p=44518#44518 for a similar topic.
_________________
Support Team
Aprelium - http://www.aprelium.com
Back to top View user's profile Send private message Send e-mail
littlestar
-


Joined: 23 Aug 2005
Posts: 7

PostPosted: Tue Oct 11, 2005 8:13 am    Post subject: Reply with quote

well, It's successful. be happy excessively when you helped
Thanks so much, my friends.
Back to top View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Aprelium Forum Index -> Perl All times are GMT + 1 Hour
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB phpBB Group