Hi All,
I received some response to my problem but
unfortunately my problem isn't solved, I'm still struggling..
Thank you all for your contribution Here is a better short code for the program which gives a clear picture of what I'm trying to ask help for. use DBI; $dsn= "dbi:mysql:db_martha:localhost"; my $user= "mysql"; my $password = "mysql123"; $dbh = DBI->connect($dsn,$user,$password); ######GET ARGS ##### $msg = $ARGV[1]; $source = $ARGV[0]; $msg =~ s/\"/' /igx; $time = localtime(); open (OUTFILE ,">>C:\\logs\\martha.txt"); print OUTFILE "$time\t$source\t$msg\n"; close(OUTFILE); $found = 0; ###### GU ##### if (($msg =~ /gu1/i) && ($msg !~ /gu1[0123456789]+/i)) { $vote = 'gu1'; $found = 1; } elsif (($msg =~ /gu2/i) && ($msg !~ /gu2[0123456789]+/i)) { $vote = 'gu2'; $found = 1; } . .some more elseif statements here . elsif (($msg =~ /gu10/i)&& ($msg !~ /gu10[0123456789]+/i)) { $vote = 'gu10'; $found = 1; } elsif (($msg =~ /gu11/i)&& ($msg !~ /gu11[0123456789]+/i)) { $vote = 'gu11'; $found = 1; } if ($found == 1) { $statement = "insert into t_count (time_in, sender, code) values (now(),'$source','$msg')"; #insert into a database $sth= $dbh->prepare("$statement"); $sth->execute; print "You entered $vote .\n"; } else { print "Error message or anything....for testing"; } $dbh->disconnect; exit; #######EndHere###### from the above code, the program accepts GU1 to GU11 but not GU 1(space before no), when i send GU 1, it jumps to the else statement. I want the program to ignore the space...... I thought by putting x on the line ($msg =~ s/\"/' /igx;) will ignore the space but it doesn't Your suggestion/help are highly appreciated... Help me please |
- Space problem Martha kavishe
- Re: Space problem Marcello
- Re: Space problem John Doe