codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  Newbie help with regex  dmkhammer at 02:40 on Monday, May 16, 2011
 

You type in a user name that is valid and it does else. Ideas as to what is happening?

if ($user =~ /^[-a-zA-Z0-9 ]+$/ )
{$user = $1;}
else
{print qq!<span style="color: rgb(255, 0, 0);">You can only have letters, spaces, and - on user name</span>\n!;
signup;
exit;}

  Re: Newbie help with regex  replytoshishir at 05:09 on Monday, May 16, 2011
 

add brackets unless you put brackets, perl will not remember the regex matched.. and thus $1 is not assigned...
i guess.. its not going to the else part.. try this..

if ($user =~ /^([-a-zA-Z0-9 ]+)$/ )

if it still goes to the else part.. let us know..


thanks and regards,
Shishir

  Re: Newbie help with regex  dmkhammer at 06:14 on Tuesday, May 17, 2011
 

Thanks for the shot at it; it still threw me to else... perhaps I am making an error earlier on that makes $user nothing?

#!/usr/bin/perl -wT
use strict;

# Load cgi routines
use CGI qw/:standard/;

# Set up my error reporting
use CGI::Carp qw(fatalsToBrowser warningsToBrowser);

# Denial of service protection
$CGI::POST_MAX=1024 * 100;
$CGI::DISABLE_UPLOADS = 1;

# Set to use file locking routine
use Fcntl qw(:flock :seek);

# Throw out the header
print "Content-type:text/html\n\n";

# Pre-Declare my subs
sub signup;
sub ReleaseLock;
sub GetLock;

# Parse the acolyte way...
my $user=param('user');

if ($user =~ /^([-a-zA-Z0-9 ]+)$/ )
{$user = $1;}
else
{print qq!<span style="color: rgb(255, 0, 0);">You can only have letters, spaces, and - on user name $user</span>\n!;
signup;
exit;}

Sub signup is pretty long...ran it through html tidy and checked for case
on user...

  Re: Newbie help with regex  dmkhammer at 06:19 on Tuesday, May 17, 2011
 

{print qq!<span style="color: rgb(255, 0, 0);">You can only have letters, spaces, and - on user name $user</span>\n!;

$user doesnt show anything on my screen...

  Re: Newbie help with regex  dmkhammer at 05:01 on Wednesday, May 18, 2011
 

I am ashamed I wasted your time on this one. I found my mistake in the html... the image jpg was coded as a href and not a submit button. I appreciate your help and I will try harder.








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
•  Re: JavaScript Word Counter
•  Re: change embed src using javascript
•  Re: DateDiff in C++
•  Re: setcapture in firefox
•  Re: C++ Inheritance Polymorphism
•  Re: toggle radio
•  Re: onclick multiple functions
•  Re: Non dereferencable iterator C++
•  Re: jslider - paint track


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2011